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,743 of 33,346   
   xmllmx to All   
   Why does initializer-list not value-init   
   16 Dec 12 19:43:54   
   
   From: xmllmx@googlemail.com   
      
   The C++11 standard 8.5.4.3 says:   
      
   "If the initializer list has no elements and T is a class type with a   
   default constructor, the object is value-initialized."   
      
   struct A   
   {   
       int get() { return i; }   
      
   private:   
       int i;   
   };   
      
   int main()   
   {   
       A a = {};   
      
       int n = a.get();   
       cout << n << endl;   
       // n is 0xCCCCCCCC rather than 0 when running in debugging mode.   
      
       return 0;   
   }   
      
   Is this a bug of VC++? My VC++ is the latest Nov 2012 CTP.   
      
      
   --   
         [ 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