I was pretty sure someone (I?) had already reported this, but I can't find it no more: --------------------------------- #include <iostream> template <int> void f () { std::cout << " "; } --------------------------------- With present mainline we get: deal.II/base> ~/tmp/build-gcc/gcc-install/bin/c++ -W -Wall -c x.cc x.cc: In function `void f()': x.cc:4: warning: statement has no effect That's clearly bogus. I thought it might be related to PR 11964 and PR 11957, but these two are already closed, whereas this still happens with last night's CVS. W.
No some reported it to the mailing list but that is all (I had told him to open a bug so it would not get lost but it looks like he did not). I can confirm this on the mainline (20030822).
I recalled it was Gerald who reported this and I searched his PRs but couldn't find ont. Seems as if he had a busy day, then. Well, now it's in bugzilla. W.
2003-09-05 Nathan Sidwell <nathan@codesourcery.com> PR c++/12037 * cp-tree.h (COMPOUND_EXPR_OVERLOADED): New. (build_min_non_dep): Declare. * tree.c (build_min): Propagate TREE_SIDE_EFFECTS. (build_min_non_dep): New. * cvt.c (convert_to_void): Don't explicitly copy TREE_SIDE_EFFECTS, TREE_NO_UNUSED_WARNING. * call.c (build_new_method_call): Use build_min_non_dep. * decl2.c (grok_array_decl): Likewise. (build_offset_ref_call_from_tree): Likewise. * typeck.c (finish_class_member_access_expr, build_x_indirect_ref, build_x_binary_op, build_x_unary_op, build_x_conditional_expr, build_x_compound_expr): Likewise. (build_static_cast, build_reinterpret_cast, build_const_cast): Propagate TREE_SIDE_EFFECTS inside a template. * typeck2.c (build_x_arrow): Use build_min_non_dep. (build_functional_cast): Propagate TREE_SIDE_EFFECTS inside a template. * rtti.c (build_dynamic_cast_1): Set DECL_IS_PURE. (build_dynamic_cast): Set TREE_SIDE_EFFECTS. * pt.c (build_non_dependent_expr): Check COMPOUND_EXPR_OVERLOADED.
Subject: Bug 12037 CVSROOT: /cvs/gcc Module name: gcc Changes by: nathan@gcc.gnu.org 2003-09-05 08:24:28 Modified files: gcc/cp : ChangeLog call.c cp-tree.h cvt.c decl2.c pt.c rtti.c tree.c typeck.c typeck2.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: noeffect4.C Log message: cp: PR c++/12037 * cp-tree.h (COMPOUND_EXPR_OVERLOADED): New. (build_min_non_dep): Declare. * tree.c (build_min): Propagate TREE_SIDE_EFFECTS. (build_min_non_dep): New. * cvt.c (convert_to_void): Don't explicitly copy TREE_SIDE_EFFECTS, TREE_NO_UNUSED_WARNING. * call.c (build_new_method_call): Use build_min_non_dep. * decl2.c (grok_array_decl): Likewise. (build_offset_ref_call_from_tree): Likewise. * typeck.c (finish_class_member_access_expr, build_x_indirect_ref, build_x_binary_op, build_x_unary_op, build_x_conditional_expr, build_x_compound_expr): Likewise. (build_static_cast, build_reinterpret_cast, build_const_cast): Propagate TREE_SIDE_EFFECTS inside a template. * typeck2.c (build_x_arrow): Use build_min_non_dep. (build_functional_cast): Propagate TREE_SIDE_EFFECTS inside a template. * rtti.c (build_dynamic_cast_1): Set DECL_IS_PURE. (build_dynamic_cast): Set TREE_SIDE_EFFECTS. * pt.c (build_non_dependent_expr): Check COMPOUND_EXPR_OVERLOADED. testsuite: PR c++/12037 * g++.dg/warn/noeffect4.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3646&r2=1.3647 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.429&r2=1.430 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.912&r2=1.913 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cvt.c.diff?cvsroot=gcc&r1=1.144&r2=1.145 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.666&r2=1.667 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.772&r2=1.773 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/rtti.c.diff?cvsroot=gcc&r1=1.172&r2=1.173 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.344&r2=1.345 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.499&r2=1.500 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&r1=1.148&r2=1.149 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3023&r2=1.3024 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/noeffect4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1