public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value
@ 2004-08-20 13:21 reichelt at gcc dot gnu dot org
  2004-08-20 13:26 ` [Bug libstdc++/17120] " reichelt at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-20 13:21 UTC (permalink / raw)
  To: gcc-bugs

This came up with Jason's recent fix for -Wparentheses (PR 17041).
Just compiling

=======================
#include<cmath>
=======================

with -Wall on mainline I get the following error message 3 times:

..../bits/cmath.tcc: In function `_Tp std::__cmath_power(_Tp, unsigned int)
[with _Tp = double]':
..../cmath:338:   instantiated from `_Tp std::__pow_helper(_Tp, int) [with _Tp =
double]'
..../cmath:353:   instantiated from here
..../bits/cmath.tcc:43: warning: suggest parentheses around assignment used as
truth value

The error message is justified, since in
gcc/libstdc++-v3/include/c_std/cmath.tcc we have:


  template<typename _Tp>
    inline _Tp
    __cmath_power(_Tp __x, unsigned int __n)
    {
      _Tp __y = __n % 2 ? __x : 1;

      while (__n >>= 1)  // line 43
        {
          __x = __x * __x;
          if (__n % 2)
            __y = __y * __x;
        }

      return __y;
    }


I'll prepare a patch soon.

-- 
           Summary: [3.5 regression] warning: suggest parentheses around
                    assignment used as truth value
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: critical
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
@ 2004-08-20 13:26 ` reichelt at gcc dot gnu dot org
  2004-08-20 14:13 ` [Bug c++/17120] " pcarlini at suse dot de
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-20 13:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-08-20 13:26 -------
Oops. Fixed already:
http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01541.html
Well, sort of.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
  2004-08-20 13:26 ` [Bug libstdc++/17120] " reichelt at gcc dot gnu dot org
@ 2004-08-20 14:13 ` pcarlini at suse dot de
  2004-08-20 14:14 ` pcarlini at suse dot de
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pcarlini at suse dot de @ 2004-08-20 14:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-08-20 14:13 -------
Actually, we don't want this warning, this is a C++ front end bug.

Jason, could you please have a look?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
          Component|libstdc++                   |c++
         Resolution|FIXED                       |


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
  2004-08-20 13:26 ` [Bug libstdc++/17120] " reichelt at gcc dot gnu dot org
  2004-08-20 14:13 ` [Bug c++/17120] " pcarlini at suse dot de
@ 2004-08-20 14:14 ` pcarlini at suse dot de
  2004-08-20 14:19 ` pcarlini at suse dot de
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pcarlini at suse dot de @ 2004-08-20 14:14 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at redhat dot com
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-08-20 14:14:07
               date|                            |


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-08-20 14:14 ` pcarlini at suse dot de
@ 2004-08-20 14:19 ` pcarlini at suse dot de
  2004-08-20 14:31 ` pcarlini at suse dot de
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pcarlini at suse dot de @ 2004-08-20 14:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-08-20 14:19 -------
.. sorry, Joseph fixed 17041, actually.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|jason at redhat dot com     |jsm28 at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-08-20 14:19 ` pcarlini at suse dot de
@ 2004-08-20 14:31 ` pcarlini at suse dot de
  2004-08-20 14:40 ` pcarlini at suse dot de
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pcarlini at suse dot de @ 2004-08-20 14:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-08-20 14:31 -------
This is small testcase:

template<typename _Tp>
  inline _Tp
  cmath_power(_Tp __x, unsigned int __n)
  {
    while (__n >>= 1)
      ;
    
    return __y;
  }

int main()
{
  cmath_power(1.0, 3);
}

-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-08-20 14:31 ` pcarlini at suse dot de
@ 2004-08-20 14:40 ` pcarlini at suse dot de
  2004-08-20 15:05 ` reichelt at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pcarlini at suse dot de @ 2004-08-20 14:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pcarlini at suse dot de  2004-08-20 14:40 -------
Actually, return __x, of course:

template<typename _Tp>
  inline _Tp
  cmath_power(_Tp __x, unsigned int __n)
  {
    while (__n >>= 1)
      ;
    return __x;
  }

int main()
{
  cmath_power(1.0, 3);
}

-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-08-20 14:40 ` pcarlini at suse dot de
@ 2004-08-20 15:05 ` reichelt at gcc dot gnu dot org
  2004-08-20 15:11 ` reichelt at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-20 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-08-20 15:05 -------
Joseph, Jason, sorry for confusing your names!
Did that in PR 17041, too. :-(


-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-08-20 15:05 ` reichelt at gcc dot gnu dot org
@ 2004-08-20 15:11 ` reichelt at gcc dot gnu dot org
  2004-08-20 15:36 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-08-20 15:11 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-08-20 15:11 ` reichelt at gcc dot gnu dot org
@ 2004-08-20 15:36 ` pinskia at gcc dot gnu dot org
  2004-08-21  0:19 ` cvs-commit at gcc dot gnu dot org
  2004-08-21  0:37 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-20 15:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-20 15:36 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-08/msg01569.html> being testing right now.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
   Target Milestone|---                         |3.5.0


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2004-08-20 15:36 ` pinskia at gcc dot gnu dot org
@ 2004-08-21  0:19 ` cvs-commit at gcc dot gnu dot org
  2004-08-21  0:37 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-21  0:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-08-21 00:19 -------
Subject: Bug 17120

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsm28@gcc.gnu.org	2004-08-21 00:19:17

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/warn: Wparentheses-4.C 

Log message:
	cp:
	PR c++/17120
	* pt.c (tsubst_copy_and_build): Avoid clearing TREE_NO_WARNING for
	MODOP_EXPR.
	
	testsuite:
	* g++.dg/warn/Wparentheses-4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4291&r2=1.4292
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.912&r2=1.913
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4168&r2=1.4169
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wparentheses-4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/17120] [3.5 regression] warning: suggest parentheses around assignment used as truth value
  2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2004-08-21  0:19 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-21  0:37 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-21  0:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-21 00:37 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-08-21  0:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-20 13:21 [Bug libstdc++/17120] New: [3.5 regression] warning: suggest parentheses around assignment used as truth value reichelt at gcc dot gnu dot org
2004-08-20 13:26 ` [Bug libstdc++/17120] " reichelt at gcc dot gnu dot org
2004-08-20 14:13 ` [Bug c++/17120] " pcarlini at suse dot de
2004-08-20 14:14 ` pcarlini at suse dot de
2004-08-20 14:19 ` pcarlini at suse dot de
2004-08-20 14:31 ` pcarlini at suse dot de
2004-08-20 14:40 ` pcarlini at suse dot de
2004-08-20 15:05 ` reichelt at gcc dot gnu dot org
2004-08-20 15:11 ` reichelt at gcc dot gnu dot org
2004-08-20 15:36 ` pinskia at gcc dot gnu dot org
2004-08-21  0:19 ` cvs-commit at gcc dot gnu dot org
2004-08-21  0:37 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).