The gcc-4.0 manual says * An expression-statement or the left-hand side of a comma expression contains no side effects. To suppress the warning, cast the unused expression to void. For example, an expression such as `x[i,j]' will cause a warning, but `x[(void)i,j]' will not. This worked for earlier releases of gcc, but in gcc-4.0 the cast to void doesn't avoid the warning. $ gcc -v Using built-in specs. Target: powerpc-apple-darwin7.8.0 Configured with: /Users/bruno/data/work/gcc-4.0.0-20050410/configure --prefix=/Volumes/UserData/experimental-macos --enable-shared --enable-version-specific-runtime-libs --enable-languages=c,c++ Thread model: posix gcc version 4.0.0 20050410 (prerelease) $ gcc -W -c foo.c foo.c: In function 'foo': foo.c:4: warning: left-hand operand of comma expression has no effect $ gcc -W -c bug.c bug.c: In function 'copy_string': bug.c:169: warning: left-hand operand of comma expression has no effect
-- Summary: "no effect" warning despite cast to void* Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bruno at clisp dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: powerpc-apple-darwin7.8.0 GCC host triplet: powerpc-apple-darwin7.8.0 GCC target triplet: powerpc-apple-darwin7.8.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21159