public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15011] New: partial ordering failure?
@ 2004-04-19 14:58 dave at boost-consulting dot com
  2004-04-19 15:01 ` [Bug c++/15011] " pinskia at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: dave at boost-consulting dot com @ 2004-04-19 14:58 UTC (permalink / raw)
  To: gcc-bugs

Should the following program compile?
-----

template <class T, class X, class R = void*>
struct enable_if_same
{};

template <class X, class R>
struct enable_if_same<X, X, R>
{
    typedef R type;
};


struct X
{
    struct ref {};
    
    X(X&);
    X();
    
    template <class T>
    X(T&, typename enable_if_same<T const, X const>::type = 0);

    operator ref();

    X(ref);
};


template <class T>
int f(T);

template <class T>
char* f(T volatile&);

X a;
char* b = f(a);

-----
GNU C++ version 3.4.0 20031231 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.2.2 20030222 (Red Hat Linux 3.2.2-5).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
foo.cpp:36: error: call of overloaded `f(X&)' is ambiguous
foo.cpp:30: note: candidates are: int f(T) [with T = X]
foo.cpp:33: note:                 char* f(volatile T&) [with T = X]

------
This also fails with gcc-3.3.1

-- 
           Summary: partial ordering failure?
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dave at boost-consulting dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
@ 2004-04-19 15:01 ` pinskia at gcc dot gnu dot org
  2004-04-19 16:39 ` bangerth at dealii dot org
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-19 15:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-19 14:50 -------
IIRC volatile is ignored in parial ordering.  There are a couple of DR and PRs about it.  PR 10807, PR 
3518.  There are some other ones too, PR 14007 and PR 2645.

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
  2004-04-19 15:01 ` [Bug c++/15011] " pinskia at gcc dot gnu dot org
@ 2004-04-19 16:39 ` bangerth at dealii dot org
  2004-04-19 17:29 ` dave at boost-consulting dot com
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-04-19 16:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-04-19 15:58 -------
The testcase is way to long and filled with stuff that doesn't 
contribute to the problem itself. Here's what it boils down 
to: 
------------- 
template <class T> int f(T); 
template <class T> char* f(T volatile&); 
 
int a; 
char* b = f(a); 
------------- 
This shows the same problem. The code compiled with 2.95, but is 
rejected as ambiguous with 3.2, 3.3, 3.4 and mainline. It compiles 
with icc7 in strict mode, though. I personally don't know whether 
it's legal or not. 
 
(Parenthetically: this constructor in your original code 
    template <class T> 
    X(T&, typename enable_if_same<T const, X const>::type = 0); 
can never be called, since the type of X can never be deduced and 
there is no way to explicitly state template parameters on a  
constructor call. But that doesn't have any impact on the problem 
in this PR.) 

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
  2004-04-19 15:01 ` [Bug c++/15011] " pinskia at gcc dot gnu dot org
  2004-04-19 16:39 ` bangerth at dealii dot org
@ 2004-04-19 17:29 ` dave at boost-consulting dot com
  2004-04-19 17:33 ` bangerth at dealii dot org
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: dave at boost-consulting dot com @ 2004-04-19 17:29 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dave at boost-consulting dot com  2004-04-19 16:15 -------
Au contraire, T can be deduced as X const.  Compile and run this:

-----
#include <cstdio>

template <class T, class X, class R = void*>
struct enable_if_same
{};

template <class X, class R>
struct enable_if_same<X, X, R>
{
    typedef R type;
};



struct X
{
    struct ref {};
    
    X(X&);
    X() {}
    
    template <class T>
    X(T&, typename enable_if_same<T const, X const>::type = 0) { std::printf
("told you so\n"); }

    operator ref();

    X(ref);
};

int main()
{
    X const x;
    X a(x);
}


-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (2 preceding siblings ...)
  2004-04-19 17:29 ` dave at boost-consulting dot com
@ 2004-04-19 17:33 ` bangerth at dealii dot org
  2004-04-19 19:25 ` pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: bangerth at dealii dot org @ 2004-04-19 17:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-04-19 16:39 -------
My bad, of course you're right. I had read the 'X' inside the 
enable_if_same<T,X> as another template parameter. 
 
This doesn't matter for this PR, though. The problem is still the 
one shown in the small snippet in comment #2. 
 
W. 

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (3 preceding siblings ...)
  2004-04-19 17:33 ` bangerth at dealii dot org
@ 2004-04-19 19:25 ` pinskia at gcc dot gnu dot org
  2004-04-19 19:37 ` dave at boost-consulting dot com
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-19 19:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-19 17:25 -------
If I remove the violate one it rejects it as the return type, char*, is different than the type 
which is expecting so maybe this invalid.
One more testcase:
template <class T> int f(T);
template <class T> char* f(T volatile&);
int a;
char* b = f(a);
int x = f(a);  //<-- should this be rejected or not, ICC rejects it as char* cannot be converted 
to directly int.

So it looks like ICC is ignoring the first template function at all.

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (4 preceding siblings ...)
  2004-04-19 19:25 ` pinskia at gcc dot gnu dot org
@ 2004-04-19 19:37 ` dave at boost-consulting dot com
  2004-04-19 21:00 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: dave at boost-consulting dot com @ 2004-04-19 19:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dave at boost-consulting dot com  2004-04-19 17:29 -------
EDG thinks they are doing the right thing with this case.  The relevant DR is 
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#214, which has WP 
status.


-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (5 preceding siblings ...)
  2004-04-19 19:37 ` dave at boost-consulting dot com
@ 2004-04-19 21:00 ` pinskia at gcc dot gnu dot org
  2004-04-19 21:27 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-19 21:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-19 17:31 -------
One more testcase, GCC and ICC both accept this one:
template <class T> int f(T);
template <class T> char* f(T volatile&);
int a;
int x = f(0);

And one more removing the volatile (as IIRC volatile here does nothing in this context),
ICC and GCC rejects this:
template <class T> int f(T);
template <class T> char* f(T &);
int a;
char* b = f(a);

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (6 preceding siblings ...)
  2004-04-19 21:00 ` pinskia at gcc dot gnu dot org
@ 2004-04-19 21:27 ` pinskia at gcc dot gnu dot org
  2004-04-20  2:28 ` giovannibajo at libero dot it
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-19 21:27 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |4672
           Keywords|                            |rejects-valid


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (7 preceding siblings ...)
  2004-04-19 21:27 ` pinskia at gcc dot gnu dot org
@ 2004-04-20  2:28 ` giovannibajo at libero dot it
  2004-04-24 18:54 ` giovannibajo at libero dot it
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-20  2:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-04-20 01:38 -------
Nathan, you worked on partial ordering lately. Care commenting on this bug? My 
current understanding is that GCC is wrong as T& (or T volatile &) is more 
specialized than T.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (8 preceding siblings ...)
  2004-04-20  2:28 ` giovannibajo at libero dot it
@ 2004-04-24 18:54 ` giovannibajo at libero dot it
  2004-04-25  0:04 ` dave at boost-consulting dot com
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-24 18:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-04-24 18:39 -------
Nathan Sidwell said: "the partial ordering rules are incomplete, because it 
ignores this kind of case. I think DR 214 is the one which fixes things. (but 
it breaks what we did in g++)".

Dave, maybe you can inquire John Spicer on this. We need an "official" position 
for this bug.

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (9 preceding siblings ...)
  2004-04-24 18:54 ` giovannibajo at libero dot it
@ 2004-04-25  0:04 ` dave at boost-consulting dot com
  2004-04-25  7:16 ` gdr at integrable-solutions dot net
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: dave at boost-consulting dot com @ 2004-04-25  0:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dave at boost-consulting dot com  2004-04-24 23:01 -------
I'm not sure what you want me to inquire.
Steve Adamczyk told me he asked John and they think they're doing the right 
thing, and referred me to DR 214.  If you want to know more, why don't you ask 
him yourself?

-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (10 preceding siblings ...)
  2004-04-25  0:04 ` dave at boost-consulting dot com
@ 2004-04-25  7:16 ` gdr at integrable-solutions dot net
  2004-04-25  9:01 ` dave at boost-consulting dot com
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-04-25  7:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-04-25 03:38 -------
Subject: Re:  partial ordering failure?

"dave at boost-consulting dot com" <gcc-bugzilla@gcc.gnu.org> writes:

| I'm not sure what you want me to inquire.
| Steve Adamczyk told me he asked John and they think they're doing the right 
| thing, and referred me to DR 214.  If you want to know more, why
| don't you ask him yourself?

I cannot speak for others. 

What I know is that Nathan Sidwell brought similar issues on the core
reflector (which you don't follow as I understand it).  It is far from
clear to me that EDG is doing the right thing and GCC is doing the
wonr thing or vice-versa, as the discussion did not reach a point of
clarification of consensus of what the right thing is (according to
the Standard specification). 

-- Gaby


-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (11 preceding siblings ...)
  2004-04-25  7:16 ` gdr at integrable-solutions dot net
@ 2004-04-25  9:01 ` dave at boost-consulting dot com
  2004-10-07  0:31 ` giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: dave at boost-consulting dot com @ 2004-04-25  9:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dave at boost-consulting dot com  2004-04-25 04:42 -------
You're right that I don't follow the core reflector.  I just want to be clear 
that I'm not claiming to know which compiler does the right thing, if any.  
I'm just reporting what EDG says to me about this issue.

I will note again that issue 214 is voted into the WP.  Whether or not issue 
214 rules definitively on this particular case (Nathan seems to think it 
does), and whether or not GCC ought to be compatible with issues that have 
been voted into the WP, are questions for you people to decide.


-- 


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (12 preceding siblings ...)
  2004-04-25  9:01 ` dave at boost-consulting dot com
@ 2004-10-07  0:31 ` giovannibajo at libero dot it
  2005-06-02  9:39 ` nathan at gcc dot gnu dot org
  2005-06-02  9:41 ` nathan at gcc dot gnu dot org
  15 siblings, 0 replies; 18+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-07  0:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-07 00:31 -------
I will confirm this bug for the time being. Since the DR is in WP status, we 
will not probably implement this in the default C++ dialect though.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-07 00:31:37
               date|                            |


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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (13 preceding siblings ...)
  2004-10-07  0:31 ` giovannibajo at libero dot it
@ 2005-06-02  9:39 ` nathan at gcc dot gnu dot org
  2005-06-02  9:41 ` nathan at gcc dot gnu dot org
  15 siblings, 0 replies; 18+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-06-02  9:39 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 15011 depends on bug 4672, which changed state.

Bug 4672 Summary: [4.0 only] [DR 214] Template parameter deduction fails for overloaded template functions.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4672

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug c++/15011] partial ordering failure?
  2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
                   ` (14 preceding siblings ...)
  2005-06-02  9:39 ` nathan at gcc dot gnu dot org
@ 2005-06-02  9:41 ` nathan at gcc dot gnu dot org
  15 siblings, 0 replies; 18+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-06-02  9:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2005-06-02 09:41 -------
I am disinclined to back port the fixes to 3.4

-- 


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


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

* [Bug c++/15011] partial ordering failure?
       [not found] <bug-15011-501@http.gcc.gnu.org/bugzilla/>
@ 2009-03-03 19:22 ` jason at gcc dot gnu dot org
  0 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-03 19:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from jason at gcc dot gnu dot org  2009-03-03 19:22 -------
DR 214 does address this case; it says that the testcase in the original
submission is ill-formed, as the two functions are both at least as specialized
as the other. [temp.deduct.partial] says that for partial ordering, we strip
the reference and any cv-qualifiers from the parameter types, so we are
comparing T and T.

EDG now gives the same error as G++.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2009-03-03 19:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-19 14:58 [Bug c++/15011] New: partial ordering failure? dave at boost-consulting dot com
2004-04-19 15:01 ` [Bug c++/15011] " pinskia at gcc dot gnu dot org
2004-04-19 16:39 ` bangerth at dealii dot org
2004-04-19 17:29 ` dave at boost-consulting dot com
2004-04-19 17:33 ` bangerth at dealii dot org
2004-04-19 19:25 ` pinskia at gcc dot gnu dot org
2004-04-19 19:37 ` dave at boost-consulting dot com
2004-04-19 21:00 ` pinskia at gcc dot gnu dot org
2004-04-19 21:27 ` pinskia at gcc dot gnu dot org
2004-04-20  2:28 ` giovannibajo at libero dot it
2004-04-24 18:54 ` giovannibajo at libero dot it
2004-04-25  0:04 ` dave at boost-consulting dot com
2004-04-25  7:16 ` gdr at integrable-solutions dot net
2004-04-25  9:01 ` dave at boost-consulting dot com
2004-10-07  0:31 ` giovannibajo at libero dot it
2005-06-02  9:39 ` nathan at gcc dot gnu dot org
2005-06-02  9:41 ` nathan at gcc dot gnu dot org
     [not found] <bug-15011-501@http.gcc.gnu.org/bugzilla/>
2009-03-03 19:22 ` jason at gcc dot gnu dot org

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