This bug only happens inside a template class or a template function, but not inside a regular function. Compile the following with g++ -W extern "C" void FormatDisk(); template <class T> struct C { C(){ FormatDisk(), 0; } // extraneous warning }; template <class T> void f() { FormatDisk(), 0; } // extraneious warning void g() { FormatDisk(), 0; } Incorrect warnings (Formatting a disk _is_ an effect, isn't it)? x.cc: In constructor `C<T>::C()': x.cc:4: warning: left-hand operand of comma expression has no effect x.cc: In function `void f()': x.cc:7: warning: left-hand operand of comma expression has no effect This is a regression introduced around 2003-07-08, probably by Mark (according to educated guesses using ChangeLogs and `cvs annotate`). It is especially bad, as Solaris system headers use constructs like this.
Confirmed as a regression from 3.3.
This is a dup of bug 11512. *** This bug has been marked as a duplicate of 11512 ***
This is not a real duplicate, in that the fix for PR11512 causes problems with the testcase of this PR: % gccvs x.cc -c -Wall x.cc: In function `void g()': x.cc:11: warning: right-hand operand of comma has no effect If don't think we should warn in this case, but _if_ we do, we should consistenly warn in all three cases, not just the ones involving templates.
2003-08-19 Nathan Sidwell <nathan@codesourcery.com> PR c++/11945 * pt.c (build_non_dependent_expr): Look inside COND_EXPR and COMPOUND_EXPR. * semantics.c (finish_expr_stmt): Always convert to void. * typeck.c (build_x_compound_exp): Always convert to void.
Subject: Bug 11945 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2003-08-20 18:00:09 Modified files: gcc/cp : ChangeLog pt.c semantics.c typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: noeffect2.C Log message: cp: PR c++/11945 * pt.c (build_non_dependent_expr): Look inside COND_EXPR and COMPOUND_EXPR. * semantics.c (finish_expr_stmt): Always convert to void. * typeck.c (build_x_compound_exp): Always convert to void. testsuite: PR c++/11945 * g++.dg/warn/noeffect2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3612&r2=1.3613 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.761&r2=1.762 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.348&r2=1.349 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.493&r2=1.494 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2982&r2=1.2983 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/noeffect2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1