This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]