Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #82731

Re: A counterintuitive breaking change related to new comparisons

From "Alf P. Steinbach" <alf.p.steinbach@gmail.com>
Newsgroups comp.lang.c++
Subject Re: A counterintuitive breaking change related to new comparisons
Date 2022-01-04 17:24 +0100
Organization A noiseless patient Spider
Message-ID <sr1scd$ljh$1@dont-email.me> (permalink)
References (1 earlier) <20220103210610.ec3859f4d0b23edfc9d217c3@cvine--nospam--.freeserve.co.uk> <sqvsdu$trp$1@dont-email.me> <20220104002324.1c51f5d1cced60e8e79a75ec@cvine--nospam--.freeserve.co.uk> <sr04ld$39j$1@dont-email.me> <sr10dd$mae$1@gioia.aioe.org>

Show all headers | View raw


On 4 Jan 2022 09:27, Juha Nieminen wrote:
> Andrey Tarasevich <andreytarasevich@hotmail.com> wrote:
>> Both `std::pair` objects are initialized with their default
>> constructors, which in turn perform value-initialization of their
>> members. In my example all `std::pair`s fields are guaranteed to be
>> initialized to zero. Nothing indeterminate here.
> 
> Are you sure "default-initialization = zero-initialization" is guaranteed
> for POD objects?
> 
> The default initialization of 'char' (as all the other primitive types) is
> "don't initialize". Is this different if the 'char' is a member of a POD
> object that has no explicit constructor?

Value initialization was about the only new feature in C++03, which was 
otherwise just Technical Corrigendum 1. It was invented by Andrew Koenig.

The point of value initialization was to guarantee initialization of 
everything, if anything in an object was initialized (e.g., an object 
with a `std::string` and a `double` should not end up with the `string` 
initialized and the `double` indeterminate, as it could in C++98).

For that purpose value initialization, used by the `std::pair` default 
constructor, ends up zero-initializing those things not otherwise 
initialized.


- Alf

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-03 09:48 -0800
  Re: A counterintuitive breaking change related to new comparisons Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2022-01-03 21:06 +0000
    Re: A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-03 14:13 -0800
      Re: A counterintuitive breaking change related to new comparisons Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2022-01-04 00:23 +0000
        Re: A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-03 16:33 -0800
          Re: A counterintuitive breaking change related to new comparisons Juha Nieminen <nospam@thanks.invalid> - 2022-01-04 08:27 +0000
            Re: A counterintuitive breaking change related to new comparisons "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-01-04 17:24 +0100
            Re: A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-04 10:26 -0800
        Re: A counterintuitive breaking change related to new comparisons Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2022-01-04 00:39 +0000
  Re: A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-03 14:24 -0800
    Re: A counterintuitive breaking change related to new comparisons "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-01-03 23:55 +0100
    Re: A counterintuitive breaking change related to new comparisons Manfred <noname@add.invalid> - 2022-01-04 00:56 +0100
      Re: A counterintuitive breaking change related to new comparisons Manfred <noname@add.invalid> - 2022-01-04 00:59 +0100
      Re: A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-03 16:59 -0800
        Re: A counterintuitive breaking change related to new comparisons Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2022-01-04 01:27 +0000
        Re: A counterintuitive breaking change related to new comparisons Öö Tiib <ootiib@hot.ee> - 2022-01-04 14:49 -0800
          Re: A counterintuitive breaking change related to new comparisons Öö Tiib <ootiib@hot.ee> - 2022-01-04 15:16 -0800
          Re: A counterintuitive breaking change related to new comparisons Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-01-05 09:06 -0800
  Re: A counterintuitive breaking change related to new comparisons "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-01-03 18:51 -0800
  Re: A counterintuitive breaking change related to new comparisons wij <wyniijj@gmail.com> - 2022-01-04 03:53 -0800
    Re: A counterintuitive breaking change related to new comparisons wij <wyniijj@gmail.com> - 2022-01-04 21:59 -0800

csiph-web