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


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

Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c++
Subject Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding
Date 2019-11-26 10:15 +0100
Organization A noiseless patient Spider
Message-ID <qriqfv$do8$1@dont-email.me> (permalink)
References (12 earlier) <qren31$fs3$1@dont-email.me> <qreqkn$51v$1@dont-email.me> <qrh5tl$aee$1@dont-email.me> <qrijrn$c5c$1@dont-email.me> <qrin5o$sd8$1@dont-email.me>

Show all headers | View raw


On 26/11/2019 09:19, Paavo Helde wrote:
> On 26.11.2019 9:22, David Brown wrote:
>> On 25/11/2019 19:18, James Kuyper wrote:
>>> On 11/24/19 3:53 PM, Soviet_Mario wrote:
>>>> Sometimes in constructors I get some warning about the
>>>> members will be initializated in a different order than
>>>> declared.
>>>
>>> That could happen through the use of access control specifiers.
>>>
>>
>> I don't think that is it.  The "-Wreorder" warning in gcc, enabled by
>> "-Wall", gives you a warning if the order of initialisers does not match
>> the order of the members:
>>
>> struct A {
>>    int i;
>>    int j;
>>    A(): j (0), i (1) { }
>> };
>>
>> That is because the compiler will actually initialise "i" first, then
>> "j" (I think the standards say this ordering is unspecified), and it
>> warns you that the order does not match what you wrote in the code.
> 
> The standard specifies the order of initialization very strictly:
> 
> "non-static data members are initialized in the order they were declared
> in the class definition ([...] regardless of the order of the
> mem-initializers)"
> 
> and even gives the reason for this order:
> 
> "[ Note: The declaration order is mandated to ensure that base and
> member subobjects are destroyed in the reverse order of initialization.
> —end note ]"
> 

Thanks for that correction.

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


Thread

Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Soviet_Mario <SovietMario@CCCP.MIR> - 2019-11-24 21:53 +0100
  Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Öö Tiib <ootiib@hot.ee> - 2019-11-24 13:46 -0800
    Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Soviet_Mario <SovietMario@CCCP.MIR> - 2019-11-25 12:44 +0100
      Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Öö Tiib <ootiib@hot.ee> - 2019-11-25 06:55 -0800
  Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-25 13:18 -0500
    Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding David Brown <david.brown@hesbynett.no> - 2019-11-26 08:22 +0100
      Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding Paavo Helde <myfirstname@osa.pri.ee> - 2019-11-26 10:19 +0200
        Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding David Brown <david.brown@hesbynett.no> - 2019-11-26 10:15 +0100
      Re: [QT creator on "nix"] - getting a strict 8 bit (1 byte) array with no padding James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-11-26 11:59 -0500

csiph-web