GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 11409 - [3.3 regression] using declarations and fabs built-in
Summary: [3.3 regression] using declarations and fabs built-in
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P1 critical
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 9396 10943 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-07-02 16:06 UTC by Richard Henderson
Modified: 2003-10-05 04:10 UTC (History)
4 users (show)

See Also:
Host: alpha-linux
Target: alpha-linux
Build: alpha-linux
Known to work:
Known to fail:
Last reconfirmed: 2003-09-06 15:59:53


Attachments
preprocessed fabs_inline test case (9.01 KB, text/plain)
2003-07-02 16:07 UTC, Richard Henderson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Henderson 2003-07-02 16:06:18 UTC
The test case fails with 

.../26_numerics/fabs_inline.cc: In function `int main()':
.../26_numerics/fabs_inline.cc:33: error: converting
   overloaded function `fabs' to type `double (*)(double)' is ambiguous
/usr/include/bits/mathinline.h:84: error: candidates are: double fabs(double)
<internal>:0: error:                 double std::fabs(double)

I believe it's not a c++ front end problem because the same .i file 
produces the same error when compiled with an i686-linux compiler.

That said, I can't figure out why this error occurs at all.  The test
case passes on i686-linux; both systems use glibc, and both systems
provide a version of fabs in /usr/include/bits/mathinline.h.

Can someone with more C++ Fu help me out?
Comment 1 Richard Henderson 2003-07-02 16:07:11 UTC
Created attachment 4328 [details]
preprocessed fabs_inline test case
Comment 2 Wolfgang Bangerth 2003-07-02 16:24:22 UTC
Here's the requested C++-fu:
This is a problem in the C++ front end with built-ins and using
declarations. Here's a smaller testcase:
-----------------------------
namespace std {
  double fabs (double);
}
using std::fabs;

double (*p) (double) = &fabs;
-----------------------------

We can compile this with 3.2.3, but 3.3 and 3.4 fail like so:
g/x> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -c y.cc
y.cc:6: error: converting overloaded function `fabs' to type `double
   (*)(double)' is ambiguous
<internal>:6: error: candidates are: double fabs(double)
y.cc:2: error:                 double std::fabs(double)


I don't think the call is ambiguous, so it should succeed. I believe that it
must have something to do with built-ins because it succeeds if fabs is
renamed to something else.

W.
Comment 3 Wolfgang Bangerth 2003-07-02 17:16:39 UTC
By the way, how could this happen that a regression tests started failing? I
thought that's why they are there for!?

W.
Comment 4 Richard Henderson 2003-07-02 17:50:54 UTC
Subject: Re:  [3.3/3.4 regression] using declarations and fabs built-in

On Wed, Jul 02, 2003 at 05:16:39PM -0000, bangerth at dealii dot org wrote:
> By the way, how could this happen that a regression tests started failing?

To my knowledge it never passed on alpha-linux.


r~
Comment 5 Gabriel Dos Reis 2003-07-04 12:01:06 UTC
Subject: Re:  New: 26_numerics/fabs_inline.cc failure

"rth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
| 
| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11409
| 
|            Summary: 26_numerics/fabs_inline.cc failure
|            Product: gcc
|            Version: 3.4
|             Status: UNCONFIRMED
|           Severity: normal
|           Priority: P2
|          Component: libstdc++
|         AssignedTo: unassigned at gcc dot gnu dot org
|         ReportedBy: rth at gcc dot gnu dot org
|                 CC: gcc-bugs at gcc dot gnu dot org
|  GCC build triplet: alpha-linux
|   GCC host triplet: alpha-linux
| GCC target triplet: alpha-linux
| 
| The test case fails with 
| 
| .../26_numerics/fabs_inline.cc: In function `int main()':
| .../26_numerics/fabs_inline.cc:33: error: converting
|    overloaded function `fabs' to type `double (*)(double)' is ambiguous
| /usr/include/bits/mathinline.h:84: error: candidates are: double fabs(double)
| <internal>:0: error:                 double std::fabs(double)

I'm almost certain that this is a bug introduced by the handling of
built-ins.  I'm certain I recently raised this issue, and discussed
the thing with Roger Sayle.

-- Gaby
Comment 6 Gabriel Dos Reis 2003-07-04 12:02:17 UTC
Subject: Re:  [3.3/3.4 regression] using declarations and fabs built-in

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| Here's the requested C++-fu:
| This is a problem in the C++ front end with built-ins and using
| declarations. Here's a smaller testcase:
| -----------------------------
| namespace std {
|   double fabs (double);
| }
| using std::fabs;
| 
| double (*p) (double) = &fabs;
| -----------------------------
| 
| We can compile this with 3.2.3, but 3.3 and 3.4 fail like so:
| g/x> /home/bangerth/bin/gcc-3.3-pre/bin/c++ -c y.cc
| y.cc:6: error: converting overloaded function `fabs' to type `double
|    (*)(double)' is ambiguous
| <internal>:6: error: candidates are: double fabs(double)
| y.cc:2: error:                 double std::fabs(double)

Yeah, this is a bug in handling the built-ins.  Roger might have
something to say on that.


This is a hot regression.

-- Gaby
Comment 7 Andrew Pinski 2003-07-06 02:08:45 UTC
*** Bug 9396 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2003-07-07 13:22:33 UTC
According to Phil's regression hunter:
Search converges between 2003-03-11-trunk (#150) and 2003-03-12-trunk (#151)
Search converges between 2003-03-10-3.3 (#76) and 2003-03-12-3.3 (#77) 
Comment 9 Andrew Pinski 2003-07-09 12:35:21 UTC
*** Bug 10943 has been marked as a duplicate of this bug. ***
Comment 10 CVS Commits 2003-09-06 16:14:34 UTC
Subject: Bug 11409

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2003-09-06 16:14:31

Modified files:
	gcc/cp         : ChangeLog class.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/overload: builtin3.C 

Log message:
	PR c++/11409
	* class.c (resolve_address_of_overloaded_function): When building
	list of matching non-template function decls, ignore anticipated
	declarations of undeclared or shadowed GCC builtins.
	
	* g++.dg/overload/builtin3.C: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3651&r2=1.3652
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.566&r2=1.567
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3029&r2=1.3030
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/builtin3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 11 CVS Commits 2003-10-05 03:47:03 UTC
Subject: Bug 11409

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	sayle@gcc.gnu.org	2003-10-05 03:46:59

Modified files:
	gcc/cp         : ChangeLog class.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/overload: builtin3.C 

Log message:
	PR c++/11409
	* class.c (resolve_address_of_overloaded_function): When building
	list of matching non-template function decls, ignore anticipated
	declarations of undeclared or shadowed GCC builtins.
	
	* g++.dg/overload/builtin3.C: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.211&r2=1.3076.2.212
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.499.2.23&r2=1.499.2.24
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.296&r2=1.2261.2.297
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/builtin3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.8.1

Comment 12 Andrew Pinski 2003-10-05 04:10:29 UTC
Fixed for 3.3.2 and 3.4.