Parentheses around return values

Started by
4 comments, last by Tanuj 23 years, 9 months ago
Chris Hargrove in part 9 of his ''Corn On The Cob'' series says thet he puts parentheses around all the return values,to prevent compiler optimization bugs. Is this really necessary?I am using MS VC++6.0 and am interested in knowing whether the parantheses make any difference.
Advertisement
Hi man;


Parantehes here and there .....

You generally not use optimise when u debug programs it slows down the compilling.

In VC++ havent heard about such problems in this compilator, but nothing is bug free.


c/c++/Java/Delphi/VB
quote:Original post by Tanuj
Chris Hargrove in part 9 of his ''Corn On The Cob'' series says thet he puts parentheses around all the return values,to prevent compiler optimization bugs.



There is no difference between these two return statements:

      return (expr);    return expr;    



HOWEVER , it is conceivable that a compiler could mess that up, so it''s certainly possible that could be the case. But if that''s so, it''s a messed-up compiler and should be smacked into submission.


---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!
You will be shocked at the number of bugs in VC. There are quite a few. Most of the common ones are fixed by the service packs.

I am not slagging it off though, I use it myself. I think most of the newer compiler have loads of bugs.

Leave of those (). There is no bug in that area (that microsoft no of, that it).

OpenGL > DirectX
Greetings,

Mossmoss, says there is no difference between
        return exp;//andreturn (exp);//What if the exp was count++? Isreturn count++;//the same asreturn (count++);    


I have not run the test yet and since I am a lazy guy I will let one of you do it. LEt me know how it turns out.

Later,
Eck

Edited by - Eck on July 21, 2000 10:02:30 AM

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

Yeah, I use MSVC regularly and know it has plenty of bugs, including standard C/C++ messups. I don''t know, in particular, if parens missing from the return statement is one of them.

Now, as to the example provided, similar to this:

    //example 1int foo(){  int count = 3;  return count++;}  //example 2int foo(){  int count = 3;  return (count++);}    


The return value is exactly the same in both cases -- 3. The value of the expression count++ is 3. The value of (expr) -- whatever expr might be -- is expr.


---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!

This topic is closed to new replies.

Advertisement