[Bug c/17257] New: Some assignment operators do not trigger "assignment used as * truth value" warning
tlambert2 at mindspring dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 1 00:12:00 GMT 2004
/*
* Some assignment operators do not trigger "assignment used as
* truth value" warning. This seems wrong. The following code,
* when compiled with "-Wall" only causes the compiler to emit a
* single warning, only for the direct assignment. The same effect
* is present on Macintosh (gcc 3.3 PPC) and Linux x86 platforms.
*/
#include <stdio.h>
#include <stdlib.h>
extern void opaque_func(int *ip, int *jp); /* avoid const optimization */
int
main(int ac, char *av[])
{
int i = 3;
int j = 1;
if( i = j) {
printf(" i and j the same\n");
}
opaque_func(&i, &j);
if (i |= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i &= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i += j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i -= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i *= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i /= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i ^= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i %= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i <<= j) {
printf("non-zero\n");
}
opaque_func(&i, &j);
if (i >>= j) {
printf("non-zero\n");
}
exit(0);
}
void
opaque_func(int *ip, int *jp)
{
*ip += 2;
*jp += 3;
}
--
Summary: Some assignment operators do not trigger "assignment
used as * truth value" warning
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tlambert2 at mindspring dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: gcc version 3.3.3 [FreeBSD] 20031106
GCC host triplet: gcc version 3.3.3 [FreeBSD] 20031106
GCC target triplet: gcc version 3.3.3 [FreeBSD] 20031106
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17257
More information about the Gcc-bugs
mailing list