On Tue, Jun 03, 2014 at 08:18:52AM +0200, Heiko Rosemann wrote: > Probably the way to do this formally correct and without relying on > implicit integer-boolean conversion would be the following: > if( (ip = s1.Intersect( s_next )) != 0 )
Best of all MISRA-C recommends if (0 != stuff()) because even in the == case, a mistyped = won't compile. Paranoid stuff, of course (to avoid memory access errors they simply somewhat banned pointers). However be careful in C++: if (stuff()) triggers an implicit to-bool conversion where if (0 != stuff()) uses an implicit to-int conversion (due to integral promotion) And for to-bool implicit conversion there is a special rule. An you could have defined an operator bool() but not an operator int(). Obviously it depends on what stuff() returns exactly... Usual C++ nasty need-to-know stuff. See http://en.cppreference.com/w/cpp/language/implicit_cast -- Lorenzo Marcantonio Logos Srl _______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

