the following file gives a warning with gcc 4.3 when using -Wall or -Wparentheses
$cat test.cc
#include <stlsoft/stlsoft.h>
void f(int foo, int bar)
{
STLSOFT_MESSAGE_ASSERT("foo bar", foo || bar);
}
$ g++ -I stlsoft-1.9.65/include/ -c test.cc -Walltest.cc: In function ‘void f(int, int)’:
test.cc:5: warning: suggest parentheses around && within ||
Whether you think the warning is useful or just annoying, it still happens.
This code (showing very bad practice by putting side effects in an assertion) causes an error:
$ cat test.cc
#include <stlsoft/stlsoft.h>
void f(int foo, int bar)
{
STLSOFT_MESSAGE_ASSERT("foo bar", foo = bar);
}
[redi@morion tmp]$ g++ -I stlsoft-1.9.65/include/ -c test.cc -Wall
test.cc: In function ‘void f(int, int)’:
test.cc:5: error: lvalue required as left operand of assignment
The attached patch is one possible fix.
surround macro argument in parentheses
Fixed (I think), as of 1.9.66; see https://sourceforge.net/forum/forum.php?forum_id=903896
Thanks. :-)