54132376   
   From: dave@boostpro.com   
      
   on Wed Apr 11 2012, Mathias Gaunard wrote:   
      
   > On Apr 9, 2:50 pm, Dave Abrahams wrote:   
   >> on Mon Apr 09 2012, Mathias Gaunard wrote:   
   >> > That's not allowed.   
   >>   
   >> Why not, if you please? It has the right alignment and is otherwise raw   
   >> memory.   
   >   
   > Because of strict aliasing rules. In practice it will work since in   
   > most compilers unions are considered aliasable by all pointer types,   
   > but that's not the case according to the language.   
   >   
   > The only types you can use to alias the content of x are void*, char*,   
   > int* and boost::aligned_storage<...>::type*.   
      
   Right, but I'm not aliasing the content of x. I'm aliasing the memory   
   that follows x.   
      
   > In practice, all real uses of aligned_storage I can think of yield   
   > undefined behaviour. I wonder how that thing ever got in TR1. Did it   
   > make it into C++11?   
      
   I presume so.   
      
   > Also I never understood why people insisted on doing a double   
   > static_cast instead of a reinterpret_cast. This is just hiding what   
   > you're actually doing.   
      
   Because it has behavior that's specified by the standard, whereas the   
   semantics of the reinterpret_cast are implementation-defined.   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
    [ 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)   
|