Bug 19203 - [3.4/4.0 Regression] [DR 214] Partial ordering failure between function reference and generic const reference
Summary: [3.4/4.0 Regression] [DR 214] Partial ordering failure between function refer...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P1 normal
Target Milestone: 4.0.1
Assignee: Nathan Sidwell
URL:
Keywords: rejects-valid
Depends on:
Blocks: 4672 12536 15674
  Show dependency treegraph
 
Reported: 2004-12-30 12:18 UTC by Giovanni Bajo
Modified: 2005-06-21 20:58 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.2 3.4.0 4.1.0
Known to fail: 3.4.3 4.0.0
Last reconfirmed: 2005-03-24 19:05:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Bajo 2004-12-30 12:18:59 UTC
Hello:


----------------------------------------------------
template <class A>
void foo(const A& a);

template <class RET, class ARG1>
void foo(RET (&)(ARG1));


float decl(int);

void bar(void)
{
  foo(decl);
}
----------------------------------------------------
lambda.cc:12: error: call of overloaded 'foo(float (&)(int))' is ambiguous
lambda.cc:2: note: candidates are: void foo(const A&) [with A = float ()(int)]
lambda.cc:5: note:                 void foo(RET (&)(ARG1)) [with RET = float, 
ARG1 = int]


I'm pretty sure that the latter overload is more specialized than the former, 
and EDG agress with me. Not sure if it is a regression.
Comment 1 Giovanni Bajo 2004-12-30 12:19:22 UTC
Bumping priority because it affects Boost.
Comment 2 Giovanni Bajo 2004-12-30 12:20:08 UTC
This is the Boost test which is failing because of this bug:
http://boost.sourceforge.net/regression-logs/cs-Linux-links.html#function-
lambda_test-gcc-4-experimental-linux
Comment 3 Andrew Pinski 2004-12-30 14:29:33 UTC
: Search converges between 2004-04-01-trunk (#447) and 2004-04-10-trunk (#448).
: Search converges between 2004-06-15-3.4 (#9) and 2004-06-27-3.4 (#10).
Comment 4 Andrew Pinski 2005-01-27 05:45:29 UTC
(In reply to comment #3)
> : Search converges between 2004-04-01-trunk (#447) and 2004-04-10-trunk (#448).
> : Search converges between 2004-06-15-3.4 (#9) and 2004-06-27-3.4 (#10).

The patches which went between both of those dates (both were by Nathan):
        PR c++/3518
        * pt.c (check_cv_quals_for_unify): Ignore bogus CV quals at outer
        level.
        PR c++/14007
        * pt.c (check_cv_quals_for_unify): Correct logic for disallowed
        cv-qualifier unification.
        * tree.c (cp_build_qualified_type_real): Renable DR295 logic.
Comment 5 Nathan Sidwell 2005-03-24 19:05:12 UTC
so I don't forget to look hard at this one
Comment 6 Nathan Sidwell 2005-03-30 13:10:19 UTC
We don't implement DR214 but edg does. 

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#214

I shall see how tricky it is to implement ...
Comment 7 GCC Commits 2005-03-31 17:36:28 UTC
Subject: Bug 19203

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2005-03-31 17:36:18

Modified files:
	gcc/cp         : ChangeLog call.c cp-tree.h pt.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/parse: ambig3.C 
Added files:
	gcc/testsuite/g++.dg/template: spec20.C spec21.C 

Log message:
	cp:
	PR c++/19203, implement DR 214
	* call.c (joust): Use more_specialized_fn.
	* cp-tree.h (DEDUCE_ORDER): Remove.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.
	* pt.c (maybe_adjust_types_for_deduction): Remove DEDUCE_ORDER
	case.
	(type_unification_real): Remove DEDUCE_ORDER case.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.  Implement DR 214.
	(most_specialized_instantiation): Use get_bindings_real directly.
	testsuite:
	PR c++/19203, DR 214
	* g++.dg/parse/ambig3.C: Not ambiguous.
	* g++.dg/template/spec20.C: New.
	* g++.dg/template/spec21.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4681&r2=1.4682
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.532&r2=1.533
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1114&r2=1.1115
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.986&r2=1.987
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5245&r2=1.5246
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/ambig3.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec20.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec21.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 Nathan Sidwell 2005-03-31 17:47:35 UTC
2005-03-31  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/19203, implement DR 214
	* call.c (joust): Use more_specialized_fn.
	* cp-tree.h (DEDUCE_ORDER): Remove.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.
	* pt.c (maybe_adjust_types_for_deduction): Remove DEDUCE_ORDER
	case.
	(type_unification_real): Remove DEDUCE_ORDER case.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.  Implement DR 214.
	(most_specialized_instantiation): Use get_bindings_real directly.

fixed on mainline.  See http://gcc.gnu.org/ml/gcc-patches/2005-03/msg02862.html
for comments about 4.0
Comment 9 Mark Mitchell 2005-03-31 18:04:48 UTC
I've retargeted this patch for GCC 4.0.1.  

After it's aged on the mainline, we can apply it to the 4.0 branch.
Comment 10 Nathan Sidwell 2005-04-04 09:49:11 UTC
Don't forget to apply the fix for 20723 as well
Comment 11 Ivan Godard 2005-04-07 07:25:28 UTC
Flagging it as ambiguous may be correct, but I agree with Nathan that it's
wrong :-)

Ivan
Comment 12 Nathan Sidwell 2005-05-10 13:29:38 UTC
fixed on 4.0 branch
2005-05-10  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/20723
	* pt.c (more_specialized_fn): Member functions are unordered wrt
	non-members.  Conversion operators are unordered wrt other
	functions.

	PR c++/19203, implement DR 214
	* call.c (joust): Use more_specialized_fn.
	* cp-tree.h (DEDUCE_ORDER): Remove.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.
	* pt.c (maybe_adjust_types_for_deduction): Remove DEDUCE_ORDER
	case.
	(type_unification_real): Remove DEDUCE_ORDER case.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.  Implement DR 214.
	(most_specialized_instantiation): Use get_bindings_real directly.

2005-05-10  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/20723
	* g++.dg/template/spec22.C: New.
	* g++.dg/template/spec23.C: New.

	PR c++/19203, DR 214
	* g++.dg/parse/ambig3.C: Not ambiguous.
	* g++.dg/template/spec20.C: New.
	* g++.dg/template/spec21.C: New.
Comment 13 GCC Commits 2005-05-10 13:48:23 UTC
Subject: Bug 19203

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	nathan@gcc.gnu.org	2005-05-10 13:48:00

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog call.c cp-tree.h pt.c 
	gcc/testsuite/g++.dg/parse: ambig3.C 
Added files:
	gcc/testsuite/g++.dg/template: spec20.C spec21.C spec22.C 
	                               spec23.C 

Log message:
	cp:
	PR c++/20723
	* pt.c (more_specialized_fn): Member functions are unordered wrt
	non-members.  Conversion operators are unordered wrt other
	functions.
	
	PR c++/19203, implement DR 214
	* call.c (joust): Use more_specialized_fn.
	* cp-tree.h (DEDUCE_ORDER): Remove.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.
	* pt.c (maybe_adjust_types_for_deduction): Remove DEDUCE_ORDER
	case.
	(type_unification_real): Remove DEDUCE_ORDER case.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.  Implement DR 214.
	(most_specialized_instantiation): Use get_bindings_real directly.
	testsuite:
	PR c++/20723
	* g++.dg/template/spec22.C: New.
	* g++.dg/template/spec23.C: New.
	
	PR c++/19203, DR 214
	* g++.dg/parse/ambig3.C: Not ambiguous.
	* g++.dg/template/spec20.C: New.
	* g++.dg/template/spec21.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.168&r2=1.5084.2.169
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.38&r2=1.4648.2.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.531.2.1&r2=1.531.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.4&r2=1.1106.2.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.8&r2=1.978.2.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/ambig3.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1&r2=1.1.84.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec20.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec21.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec22.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec23.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.2.10.1

Comment 14 Wolfgang Bangerth 2005-06-21 20:58:57 UTC
Unfortunately, the patch to this PR has caused the regression reported in 
PR 21799 :-( 
 
W.