Hi Sukender, On Thu, Jan 8, 2009 at 11:28 AM, Sukender <suky0...@free.fr> wrote: > I'm sorry to come late in the discussion, but I did not understand why you > say the "assignment within conditional expression" warning (C4706 under MSVC) > is useless. I know it is correct C/C++ to write "if (a=b)", but haven't you > ever typed "a=b" instead if "a==b" in a "if" statement? It happens often to > me... :) In all my projects, I set this warning to be an error so that it > doesn't compile. > But I understand (and agree) that putting "!=0" everywhere could be a pain > for those who aren't used to.
The converse also happens, sometimes there are places where if (a==b) is used but if (a=b) is meant, I know because I fixed one such error yesterday, yet the warning doesn't catch this... rather I think this warning led to previous contributor to this particular code "fixing" the warning by breaking the code. The reality is that compiler can't catch algorithm errors, catching algorithm errors is our job, and job that can be hindered by syntactical tricks that one has to employ to quieten down these over zealous warnings. Algorithm errors are more of pervasive problem than syntactical errors. Code readability is key to spotting algorithm errors, so any slip in readability is something to take very seriously which is why the !=0 is not what I would deem a good programming practice. Robert. _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org