* [Bug c++/37582] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
@ 2008-09-19 7:34 ` jarausch at igpm dot rwth-aachen dot de
2008-09-19 7:36 ` jarausch at igpm dot rwth-aachen dot de
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jarausch at igpm dot rwth-aachen dot de @ 2008-09-19 7:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jarausch at igpm dot rwth-aachen dot de 2008-09-19 07:33 -------
Created an attachment (id=16360)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16360&action=view)
preprocessed failing source code
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
2008-09-19 7:34 ` [Bug c++/37582] " jarausch at igpm dot rwth-aachen dot de
@ 2008-09-19 7:36 ` jarausch at igpm dot rwth-aachen dot de
2008-09-19 9:35 ` [Bug c++/37582] [4.3 Regression] " rguenth at gcc dot gnu dot org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jarausch at igpm dot rwth-aachen dot de @ 2008-09-19 7:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jarausch at igpm dot rwth-aachen dot de 2008-09-19 07:35 -------
gcc -v -save-temps -c TEST3.C
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.3.1-r1/work/gcc-4.3.1/configure --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.1
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.1/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --disable-multilib --enable-libmudflap
--disable-libssp --enable-cld --enable-java-awt=gtk --with-arch=i686
--enable-languages=c,c++,java,treelang,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.1-r1 p1.1'
Thread model: posix
gcc version 4.3.1 (Gentoo 4.3.1-r1 p1.1)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-mtune=generic' '-march=i686'
/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -E -quiet -v -D_GNU_SOURCE
TEST3.C -mtune=generic -march=i686 -fpch-preprocess -o TEST3.ii
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4/i686-pc-linux-gnu
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4/backward
/usr/local/include
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include-fixed
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-mtune=generic' '-march=i686'
/usr/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -fpreprocessed TEST3.ii
-quiet -dumpbase TEST3.C -mtune=generic -march=i686 -auxbase TEST3 -version -o
TEST3.s
GNU C++ (Gentoo 4.3.1-r1 p1.1) version 4.3.1 (i686-pc-linux-gnu)
compiled by GNU C version 4.3.1, GMP version 4.2.3, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 80bbbbf6aed7cf0c473d383e5ba3eede
TEST3.C: In function 'double S_Precision::square(double)':
TEST3.C:57: error: ISO C++ says that these are ambiguous, even though the worst
conversion for the first is better than the worst conversion for the second:
TEST3.C:57: note: candidate 1: operator&&(bool, bool) <built-in>
TEST3.C:46: note: candidate 2: bool S_Precision::operator&&(int, const
S_Precision::super_real&)
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4/cmath:389: error: ISO C++
says that these are ambiguous, even though the worst conversion for the first
is better than the worst conversion for the second:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.1/include/g++-v4/cmath:389: note: candidate
1: operator&&(bool, bool) <built-in>
TEST3.C:46: note: candidate 2: bool S_Precision::operator&&(int, const
S_Precision::super_real&)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
2008-09-19 7:34 ` [Bug c++/37582] " jarausch at igpm dot rwth-aachen dot de
2008-09-19 7:36 ` jarausch at igpm dot rwth-aachen dot de
@ 2008-09-19 9:35 ` rguenth at gcc dot gnu dot org
2008-09-22 19:57 ` pinskia at gcc dot gnu dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-19 9:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2008-09-19 09:34 -------
Shorter testcase:
#include <cmath>
class super_real {
public:
super_real (double);
};
bool operator&& (int i, const super_real& a);
double square(double a) {
return std::pow(a,2.0);
}
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Known to fail| |4.3.0 4.3.2
Known to work| |4.2.4 4.4.0
Priority|P3 |P1
Last reconfirmed|0000-00-00 00:00:00 |2008-09-19 09:34:07
date| |
Summary|std::pow strange overload |[4.3 Regression] std::pow
|resolution |strange overload resolution
Target Milestone|--- |4.3.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (2 preceding siblings ...)
2008-09-19 9:35 ` [Bug c++/37582] [4.3 Regression] " rguenth at gcc dot gnu dot org
@ 2008-09-22 19:57 ` pinskia at gcc dot gnu dot org
2008-10-22 21:24 ` jakub at gcc dot gnu dot org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-22 19:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2008-09-22 19:55 -------
Is && part of GNU C++98 now?
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (3 preceding siblings ...)
2008-09-22 19:57 ` pinskia at gcc dot gnu dot org
@ 2008-10-22 21:24 ` jakub at gcc dot gnu dot org
2008-12-11 11:47 ` rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-10-22 21:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2008-10-22 21:22 -------
Couldn't cmath just use:
template<typename _Tp, typename _Up>
inline
typename __gnu_cxx::__promote_2<
- typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
- && __is_arithmetic<_Up>::__value,
+ typename __gnu_cxx::__enable_if<bool(__is_arithmetic<_Tp>::__value)
+ && bool(__is_arithmetic<_Up>::__value),
_Tp>::__type, _Up>::__type
pow(_Tp __x, _Up __y)
{
...
? Though 4.4 cc1plus doesn't complain...
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bkoz at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (4 preceding siblings ...)
2008-10-22 21:24 ` jakub at gcc dot gnu dot org
@ 2008-12-11 11:47 ` rguenth at gcc dot gnu dot org
2008-12-11 17:21 ` hjl dot tools at gmail dot com
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-12-11 11:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2008-12-11 11:45 -------
Janis, can we have your regression hunting services to look what fixed this
on the mainline?
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |janis at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (5 preceding siblings ...)
2008-12-11 11:47 ` rguenth at gcc dot gnu dot org
@ 2008-12-11 17:21 ` hjl dot tools at gmail dot com
2008-12-11 17:26 ` jakub at gcc dot gnu dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-12-11 17:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from hjl dot tools at gmail dot com 2008-12-11 17:20 -------
It is fixed by revision 133519:
http://gcc.gnu.org/ml/gcc-cvs/2008-03/msg00738.html
http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01285.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (6 preceding siblings ...)
2008-12-11 17:21 ` hjl dot tools at gmail dot com
@ 2008-12-11 17:26 ` jakub at gcc dot gnu dot org
2008-12-11 19:56 ` [Bug libstdc++/37582] " jakub at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-11 17:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jakub at gcc dot gnu dot org 2008-12-11 17:25 -------
That looks very invasive for the branch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (7 preceding siblings ...)
2008-12-11 17:26 ` jakub at gcc dot gnu dot org
@ 2008-12-11 19:56 ` jakub at gcc dot gnu dot org
2008-12-11 20:06 ` paolo dot carlini at oracle dot com
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-11 19:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jakub at gcc dot gnu dot org 2008-12-11 19:55 -------
Created an attachment (id=16888)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16888&action=view)
gcc43-pr37582.patch
Given:
// N.B. The conversions to bool are needed due to the issue
// explained in c++/19404.
template<class _Sp, class _Tp>
struct __traitor
{
enum { __value = bool(_Sp::__value) || bool(_Tp::__value) };
typedef typename __truth_type<__value>::__type __type;
};
I see this isn't the first time libstdc++ works around the C++ bug.
So, either IMHO we should cast to bool there, or as done in this patch
use __traitor instead.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (8 preceding siblings ...)
2008-12-11 19:56 ` [Bug libstdc++/37582] " jakub at gcc dot gnu dot org
@ 2008-12-11 20:06 ` paolo dot carlini at oracle dot com
2008-12-11 20:35 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-12-11 20:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from paolo dot carlini at oracle dot com 2008-12-11 20:04 -------
(In reply to comment #9)
> So, either IMHO we should cast to bool there, or as done in this patch
> use __traitor instead.
For the branch, I pre-approve a patch adding and using __traitand.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (9 preceding siblings ...)
2008-12-11 20:06 ` paolo dot carlini at oracle dot com
@ 2008-12-11 20:35 ` jakub at gcc dot gnu dot org
2008-12-12 8:48 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-11 20:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jakub at gcc dot gnu dot org 2008-12-11 20:32 -------
Created an attachment (id=16889)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16889&action=view)
gcc43-pr37582.patch
Thanks for pointing the difference between || and &&, embarrassing.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #16888|0 |1
is obsolete| |
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (10 preceding siblings ...)
2008-12-11 20:35 ` jakub at gcc dot gnu dot org
@ 2008-12-12 8:48 ` jakub at gcc dot gnu dot org
2008-12-12 8:54 ` jakub at gcc dot gnu dot org
2008-12-12 11:24 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-12 8:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jakub at gcc dot gnu dot org 2008-12-12 08:47 -------
Subject: Bug 37582
Author: jakub
Date: Fri Dec 12 08:46:26 2008
New Revision: 142704
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142704
Log:
PR c++/37582
* include/bits/cpp_type_traits.h (struct __traitand): New.
* include/c_global/cmath (std::atan2, std::pow): Use __traitand
instead of && as first argument to __enable_if.
* include/c_std/cmath (std::atan2): Likewise.
* testsuite/26_numerics/headers/cmath/37582.cc: New.
Added:
branches/gcc-4_3-branch/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc
Modified:
branches/gcc-4_3-branch/libstdc++-v3/ChangeLog
branches/gcc-4_3-branch/libstdc++-v3/include/bits/cpp_type_traits.h
branches/gcc-4_3-branch/libstdc++-v3/include/c_global/cmath
branches/gcc-4_3-branch/libstdc++-v3/include/c_std/cmath
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (11 preceding siblings ...)
2008-12-12 8:48 ` jakub at gcc dot gnu dot org
@ 2008-12-12 8:54 ` jakub at gcc dot gnu dot org
2008-12-12 11:24 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-12 8:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jakub at gcc dot gnu dot org 2008-12-12 08:51 -------
Fixed.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug libstdc++/37582] [4.3 Regression] std::pow strange overload resolution
2008-09-19 7:33 [Bug c++/37582] New: std::pow strange overload resolution jarausch at igpm dot rwth-aachen dot de
` (12 preceding siblings ...)
2008-12-12 8:54 ` jakub at gcc dot gnu dot org
@ 2008-12-12 11:24 ` jakub at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-12-12 11:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from jakub at gcc dot gnu dot org 2008-12-12 11:23 -------
Subject: Bug 37582
Author: jakub
Date: Fri Dec 12 11:22:33 2008
New Revision: 142707
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142707
Log:
PR c++/37582
* testsuite/26_numerics/headers/cmath/37582.cc: New.
Added:
trunk/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc
Modified:
trunk/libstdc++-v3/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37582
^ permalink raw reply [flat|nested] 15+ messages in thread