public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31511]  New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
@ 2007-04-08 20:03 bav dot 272304 at gmail dot com
  2007-04-08 20:12 ` [Bug libstdc++/31511] " pcarlini at suse dot de
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bav dot 272304 at gmail dot com @ 2007-04-08 20:03 UTC (permalink / raw)
  To: gcc-bugs

It is known problem with GNU ISO C++ Library math implementation by Gabriel Dos
Reis.

g++ compiler says something like this:

        /usr/include/c++/bits/cmath.tcc:41: error: no match for
        ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'

It could be fixed by replacing the certain line at the cmath.tcc file

        _Tp __y = __n % 2 ? __x : 1;

with more correct

        _Tp __y = __n % 2 ? __x : _Tp(1);

(see cmath.tcc for details)

To reproduce error, try to pass to std::pow() std::complex<T> object where T
isn't primitive type but some class with arithmetic operators overloaded.

I found it in g++ 3.3.5, g++ 4.0.0, etc.


-- 
           Summary: /usr/include/c++/bits/cmath.tcc: no match for ternary
                    'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bav dot 272304 at gmail dot com


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
@ 2007-04-08 20:12 ` pcarlini at suse dot de
  2007-04-08 20:16 ` [Bug c++/31511] " bav dot 272304 at gmail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-04-08 20:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pcarlini at suse dot de  2007-04-08 21:12 -------
Gaby, not a big deal (complex<t> is unspecified for T != floating, ...), but
what do you think, shall we do the 1 -> _Tp(1) change?


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pcarlini at suse dot de, gdr
                   |                            |at integrable-solutions dot
                   |                            |net
          Component|c++                         |libstdc++


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


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

* [Bug c++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
  2007-04-08 20:12 ` [Bug libstdc++/31511] " pcarlini at suse dot de
@ 2007-04-08 20:16 ` bav dot 272304 at gmail dot com
  2007-04-08 20:17 ` bav dot 272304 at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bav dot 272304 at gmail dot com @ 2007-04-08 20:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bav dot 272304 at gmail dot com  2007-04-08 21:16 -------
Code example:

============================================================

#include <complex>

template<typename T> class Wrapper {
        T x_;
public:
        Wrapper () throw () : x_(0) {}
        Wrapper (const T& x) throw () : x_(x) {}
        Wrapper operator* (const Wrapper& x) const throw () {
                return Wrapper (x_*x.x_);
        }
        Wrapper operator/ (const Wrapper& x) const throw () {
                return Wrapper (x_/x.x_);
        }
        Wrapper operator+ (const Wrapper& x) const throw () {
                return Wrapper (x_+x.x_);
        }
        Wrapper operator- (const Wrapper& x) const throw () {
                return Wrapper (x_-x.x_);
        }
        Wrapper operator- () const throw () {
                return Wrapper (-x_);
        }
        ~Wrapper () throw () {}
};

int main () {

        std::complex <Wrapper<double> > x (Wrapper<double>(2.0));
        std::pow (x, 23);

}

============================================================

OUTPUT:

debian:/# g++ bug.cpp --pedantic --std=c++98 -Wall
/usr/include/c++/3.3/bits/cmath.tcc: In function `_Tp std::__cmath_power(_Tp,
   unsigned int) [with _Tp = std::complex<Wrapper<double> >]':
/usr/include/c++/3.3/cmath:477:   instantiated from `_Tp std::__pow_helper(_Tp,
int) [with _Tp = std::complex<Wrapper<double> >]'
/usr/include/c++/3.3/complex:564:   instantiated from `std::complex<_Tp>
std::pow(const std::complex<_Tp>&, int) [with _Tp = Wrapper<double>]'
bug.cpp:29:   instantiated from here
/usr/include/c++/3.3/bits/cmath.tcc:42: error: no match for ternary
   'operator?:' in '((__n % 2) != 0) ? __x : 1'


-- 

bav dot 272304 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bav dot 272304 at gmail dot
                   |                            |com
          Component|libstdc++                   |c++


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


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

* [Bug c++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
  2007-04-08 20:12 ` [Bug libstdc++/31511] " pcarlini at suse dot de
  2007-04-08 20:16 ` [Bug c++/31511] " bav dot 272304 at gmail dot com
@ 2007-04-08 20:17 ` bav dot 272304 at gmail dot com
  2007-04-08 20:20 ` [Bug libstdc++/31511] " pcarlini at suse dot de
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bav dot 272304 at gmail dot com @ 2007-04-08 20:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bav dot 272304 at gmail dot com  2007-04-08 21:17 -------
(In reply to comment #1)
> Gaby, not a big deal (complex<t> is unspecified for T != floating, ...), but
> what do you think, shall we do the 1 -> _Tp(1) change?
> 

No, everything works if we fix this bug.


-- 


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (2 preceding siblings ...)
  2007-04-08 20:17 ` bav dot 272304 at gmail dot com
@ 2007-04-08 20:20 ` pcarlini at suse dot de
  2007-04-08 20:21 ` [Bug c++/31511] " bav dot 272304 at gmail dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-04-08 20:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pcarlini at suse dot de  2007-04-08 21:20 -------
(In reply to comment #3)
> (In reply to comment #1)
> > Gaby, not a big deal (complex<t> is unspecified for T != floating, ...), but
> > what do you think, shall we do the 1 -> _Tp(1) change?
> > 
> 
> No, everything works if we fix this bug.

The issue is clear, thanks. I repeat that strictly speaking std::complex could
do anything it wants for T != floating type, but I agree that it would make
sense to do the change.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++


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


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

* [Bug c++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (3 preceding siblings ...)
  2007-04-08 20:20 ` [Bug libstdc++/31511] " pcarlini at suse dot de
@ 2007-04-08 20:21 ` bav dot 272304 at gmail dot com
  2007-04-08 20:22 ` [Bug libstdc++/31511] " pcarlini at suse dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bav dot 272304 at gmail dot com @ 2007-04-08 20:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from bav dot 272304 at gmail dot com  2007-04-08 21:21 -------
(In reply to comment #1)
> but what do you think, shall we do the 1 -> _Tp(1) change?

Change, please.


-- 

bav dot 272304 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |c++


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (4 preceding siblings ...)
  2007-04-08 20:21 ` [Bug c++/31511] " bav dot 272304 at gmail dot com
@ 2007-04-08 20:22 ` pcarlini at suse dot de
  2007-04-08 20:53 ` gdr at cs dot tamu dot edu
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-04-08 20:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2007-04-08 21:22 -------
Please, stop categorizing wrong.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (5 preceding siblings ...)
  2007-04-08 20:22 ` [Bug libstdc++/31511] " pcarlini at suse dot de
@ 2007-04-08 20:53 ` gdr at cs dot tamu dot edu
  2007-04-08 22:36 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at cs dot tamu dot edu @ 2007-04-08 20:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from gdr at cs dot tamu dot edu  2007-04-08 21:53 -------
Subject: Re:  /usr/include/c++/bits/cmath.tcc: no match for ternary
'operator?:' in '((__n % 2u) != 0u) ? __x : 1'

"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:

| Gaby, not a big deal (complex<t> is unspecified for T != floating, ...), but
| what do you think, shall we do the 1 -> _Tp(1) change?

Sounds good.

-- Gaby


-- 


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (6 preceding siblings ...)
  2007-04-08 20:53 ` gdr at cs dot tamu dot edu
@ 2007-04-08 22:36 ` pcarlini at suse dot de
  2007-04-08 22:38 ` paolo at gcc dot gnu dot org
  2007-04-08 22:39 ` pcarlini at suse dot de
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-04-08 22:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-04-08 23:36:18
               date|                            |


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (7 preceding siblings ...)
  2007-04-08 22:36 ` pcarlini at suse dot de
@ 2007-04-08 22:38 ` paolo at gcc dot gnu dot org
  2007-04-08 22:39 ` pcarlini at suse dot de
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-04-08 22:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo at gcc dot gnu dot org  2007-04-08 23:38 -------
Subject: Bug 31511

Author: paolo
Date: Sun Apr  8 23:37:56 2007
New Revision: 123665

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123665
Log:
2007-04-08  Alexey Beshenov  <bav.272304@gmail.com>

        PR libstdc++/31511
        * include/c_global/cmath.tcc (__cmath_power): Use _Tp(1).
        * include/c_std/cmath.tcc (__cmath_power): Likewise.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/c_global/cmath.tcc
    trunk/libstdc++-v3/include/c_std/cmath.tcc


-- 


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


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

* [Bug libstdc++/31511] /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1'
  2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
                   ` (8 preceding siblings ...)
  2007-04-08 22:38 ` paolo at gcc dot gnu dot org
@ 2007-04-08 22:39 ` pcarlini at suse dot de
  9 siblings, 0 replies; 11+ messages in thread
From: pcarlini at suse dot de @ 2007-04-08 22:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pcarlini at suse dot de  2007-04-08 23:38 -------
Fixed.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-04-08 22:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-08 20:03 [Bug c++/31511] New: /usr/include/c++/bits/cmath.tcc: no match for ternary 'operator?:' in '((__n % 2u) != 0u) ? __x : 1' bav dot 272304 at gmail dot com
2007-04-08 20:12 ` [Bug libstdc++/31511] " pcarlini at suse dot de
2007-04-08 20:16 ` [Bug c++/31511] " bav dot 272304 at gmail dot com
2007-04-08 20:17 ` bav dot 272304 at gmail dot com
2007-04-08 20:20 ` [Bug libstdc++/31511] " pcarlini at suse dot de
2007-04-08 20:21 ` [Bug c++/31511] " bav dot 272304 at gmail dot com
2007-04-08 20:22 ` [Bug libstdc++/31511] " pcarlini at suse dot de
2007-04-08 20:53 ` gdr at cs dot tamu dot edu
2007-04-08 22:36 ` pcarlini at suse dot de
2007-04-08 22:38 ` paolo at gcc dot gnu dot org
2007-04-08 22:39 ` pcarlini at suse dot de

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