This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
"suggest parentheses around assignment used as truth value" warning bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: "suggest parentheses around assignment used as truth value" warning bug
- From: Josh Wilmes <jwilmes at cisco dot com>
- Date: Tue, 23 Nov 1999 15:23:34 -0800
The file "test.cpp" (attached) uses an assignment as a truth value in three
places. However, one of them (where it occurs inside a templated class) does
not generate a warning. We just found such a bug in a program here and were
surprised that the compiler hadn't caught it.
I didn't see any mention of this bug in the 2.95.2 release notes, but if it
has already been fixed, let me know.
Thanks,
--Josh
--
Josh Wilmes - jwilmes@cisco.com
jwilmes@jwilmes-sun:~/gcc-bug$ gcc -v
Reading specs from /usr/SD/gnu.dev/lib/gcc-lib/sparc-sun-solaris2.6/2.95.1/specs
gcc version 2.95.1 19990816 (release)
jwilmes@jwilmes-sun:~/gcc-bug$ uname -a
SunOS jwilmes-sun 5.6 Generic_105181-03 sun4u sparc SUNW,Ultra-5_10
jwilmes@jwilmes-sun:~/gcc-bug$ make test
g++ -Wall test.cpp -o test
test.cpp: In method `void anotherclass::amethod()':
test.cpp:18: warning: suggest parentheses around assignment used as truth value
test.cpp: In function `int main(int, char **)':
test.cpp:28: warning: suggest parentheses around assignment used as truth value
template<class T>
class aclass {
public:
void amethod(void) {
int var;
if (var = 0)
return;
}
};
class anotherclass {
public:
void amethod(void) {
int var;
if (var = 0)
return;
}
};
int main (int argc, char* argv[]) {
int var;
if (var = 0)
return 0;
}