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,325 of 33,346   
   Pete Becker to rado   
   Re: postfix operator++   
   22 May 12 17:13:25   
   
   f29e377d   
   From: pete@versatilecoding.com   
      
   On 2012-05-22 19:10:09 +0000, rado said:   
      
   >>   
   >> You have invoked undefined behaviour because your assignment   
   >> statement modifies x twice without an intervening sequence   
   >> point. This is always a no no in C and C++ for built-in types. The   
   >> same rule applies to struct/class types except that in most   
   >> instances where it looks as this has been done (2 modifications to   
   >> same memory between sequence points) there are some hidden sequence   
   >> points because overloaded operators are actually function calls.   
   >   
   > I wonder why decent compilers don't issue a warning in such cases.  Or   
   > maybe they do. Does anybody know?   
      
   It's rather pointless to warn about beginners' errors. The real cases   
   where this kind of thing bites you can't be recognized easily at   
   compile time, and beginners who got used to having their hands held   
   would find themselves suddenly lost without having developed the skills   
   to recognize the problem.   
      
   --   
    Pete   
   Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The   
   Standard C++ Library Extensions: a Tutorial and Reference   
   (www.petebecker.com/tr1book)   
      
      
         [ 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