home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,231 of 33,346   
   Andy Champ to red floyd   
   Re: Union padding   
   01 May 12 15:04:17   
   
   From: no.way@nospam.invalid   
      
   On 30/04/2012 23:42, red floyd wrote:   
   > On 4/30/2012 1:08 PM, Daryle Walker wrote:   
   >>   
   >> I've been testing out types like:   
   >>   
   >> union   
   >> {   
   >> T1 a;   
   >> T2 b;   
   >> union   
   >> {   
   >> T3 ca;   
   >> T4 cb;   
   >> } c;   
   >> } d;   
   >>   
   >> [redacted]   
   >> Looking at Section 9.5 Paragraph 1 in the copy of C++11   
   >> I just bought, and it seems that my desired behavior isn't guaranteed.   
   >> There may be padding between the start of the union and any of its   
   >> members, and the padding for each member may differ. Am I accurate in   
   >> this assessment?   
   >>   
   >> From N3242. 9.5/5 The final sentence of the example implicitly notes   
   > that union members all have the same address. I'm not sure if this is   
   > normative or not.   
   >   
   >   
      
   OK, I'm going on memory here, so I could easily be wrong... but... I   
   though the returned data from a new was guaranteed to be at an alignment   
   which is suitable for any type?  In which case even though a compiler   
   writer might be _allowed_ to pad the beginning, why on earth would they   
   do it?   
      
   That said...   
      
      
   Andy   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca