Your recommendation below seems like it would depend on what type fxn()
returns, am I correct?

For example, if fxn() returns an int (and 'a' is declared as an int), then
the following is correct:
    "if ( (a = fxn()) != 0 )

But the above is incorrect - and possibly inefficient - if fxn() returns a
bool (and 'a' is declared as a bool), because that code would causes a bool
to be compared against an int (0). If fxn() returns a bool, the following
should be sufficient (and should not generate a warning IMHO):
    "if ( a = fxn() )"

This is off topic for a scene graph mailing list, but I would like to
prevent someone from going through the code and doing a blanket replace of
good code with bad code.

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
+1 303 859 9466

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Matthew
Fuesz
Sent: Wednesday, January 07, 2009 9:36 AM
To: [email protected]
Subject: Re: [osg-users] Warning level


Skylark (J-S) wrote:
> 
> I'm fine with suppressing C4706 as it's true that it's a warning that 
> only tells you that you *might* be doing something unsafe... Whether 
> it's actually safe or not is totally context-dependent.
> 


Blanket-supression of C4706 isn't really a good thing, since as you pointed
out, it can actually point out an error (usually a typo by the developer).
C4706 will not be generated if it is made explicitly clear what the intent
of the conditional is.

i.e., instead of checking "if ( a = fxn() )", check "if ( (a = fxn()) != 0
)". This is covered in the MSDN page on C4706.

I actually prefer the latter syntax (which doesn't generate C4706) anyway,
since it eliminates any possible confusion as to the intended operations.

------------------------
Matthew W Fuesz
Software Engineer Asc
Lockheed Martin STS

------------------
Read this topic online here:
http://osgforum.tevs.eu/viewtopic.php?p=4253#4253





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to