[Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Aug 20 15:11:00 GMT 2004


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-08-20 15:11 -------
As for a testcase, one should probably extend Wparentheses-3.C a little bit:

====================================================================
--- Wparentheses-3.C   2004-08-20 17:07:20.000000000 +0200
+++ Wparentheses-3.C   2004-08-20 17:08:21.000000000 +0200
@@ -1,5 +1,5 @@
 // Test that -Wparentheses does not give bogus warnings in the
-// presence of templates.  Bug 17041.
+// presence of templates.  PR c++/17041 and PR c++/17120.
 
 // { dg-do compile }
 // { dg-options "-Wparentheses" }
@@ -7,7 +7,11 @@
 template<int> struct A
 {
     int i;
-    A() { if ((i = 0)) ; }
+    A()
+    {
+        if ((i = 0)) ;
+        if (i >>= 0) ;
+    }
 };
 
 A<0> a;
====================================================================


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17120



More information about the Gcc-bugs mailing list