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,834 of 33,346   
   goran.pusic@googlemail.com to Zeljko Vrba   
   Re: iostream replacement   
   28 Jan 13 12:05:57   
   
   On Saturday, January 26, 2013 7:17:27 PM UTC+1, Zeljko Vrba wrote:   
   > On 2013-01-25, JamK. Lown  wrote:   
   > > On Thu, 24 Jan 2013 23:59:38 -0800 (PST)   
   > > fma5876  wrote:   
   > >   
   > >   
   > >> first example of operator overloading abuse.   
   > >   
   > > Define abuse, please.   
   >   
   > This has bitten me more than once:   
   >   
   >   cout << modify_x() << x << endl;   
   >   
   > Unspecified evaluation order of function arguments.  It's something   
   > that I'm normally aware of while calling ordinary functions.  Here,   
   > the context and the operator conspire to mislead one to believe that   
   > left-to-right sequencing will take place, whereas it does not; the   
   > compiler transforms this to nested function calls.   
      
   This is... ahem... unfair ;-)   
      
   But the sequence point is at the end of the statement, regardless of   
   whether you have printf("fmt", modify_x(), x) or operators. You use   
   operators in plain C and can screw it up in much the same way, e.g. I   
   dunno,   
      
   whatever = modify_x() << 9 | x;   
      
   Hereby I am stating Goran's theorem of C vs. C++ coding: C++ does a   
   lot of things badly, but none worse than plain C :-).   
      
   Goran.   
      
      
   --   
         [ 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