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 33,244 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to James K. Lowden   
   Re: is using memcopy() to manipulate arr   
   10 Oct 13 09:57:33   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2013-10-10 08:38, James K. Lowden wrote:   
   > You seem to assume here that syndrome is initialized to zeros.  It's   
   > not, or at least won't always be.  You can say   
   >   
   > 	int syndrome[4] = {0};   
   >   
   > because the standard says that remaining elements are initialized to   
   > the the last provided initialization value.  Roughly.   
      
   Actually the wording says that the remaining elements will be   
   initialized with empty list initialization, therefore the first value is   
   not needed at all. Personally I always recommend to use the more   
   generally valid (and more concise) form   
      
   int syndrome[4] = {};   
      
   instead that has already been guaranteed to work as expected in C++03.[1]   
      
   Unfortunately there still exists modern compilers that spit warnings on   
   that construction with misleading contents. If you meet such a compiler,   
   this is a good occasion to send a corresponding bug report to the vendor ;-)   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
   [1] C++03 says that {} causes value-initialization for all elements of   
   an aggregate and in C++11 it says that empty list initialization is   
   performed, but for well-formed C++03 code this doesn't make any difference.   
      
      
   --   
         [ 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