public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23513] New: overload resolution fails to select a more specialized template
@ 2005-08-22  9:48 maxim dot yegorushkin at gmail dot com
  2005-08-22 11:17 ` [Bug c++/23513] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: maxim dot yegorushkin at gmail dot com @ 2005-08-22  9:48 UTC (permalink / raw)
  To: gcc-bugs

This well-formed complete source is rejected by g++, but compiles fine 
with comeau online 4.3.3 BETA August 4, 2003.
A related discussion on clc++ http://groups-beta.google.com/group/comp.
lang.c++/msg/1475f4e8f1ff9982

struct A
{
    template<class T> void operator<<(T&);
};

template<class T> struct B {};
template<class T> void operator<<(A&, B<T>&);

int main()
{
    A a;
    B<A> b;
    a << b;
}

[max@localhost exp]$ g++ -v -save-temps -Wall exp.cpp -o exp
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-
checking=release --with-system-zlib --enable-__cxa_atexit --disable-
libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,
objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/
java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
 /usr/libexec/gcc/i386-redhat-linux/4.0.1/cc1plus -E -quiet -v -
D_GNU_SOURCE exp.cpp -Wall -fpch-preprocess -o exp.ii
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../
i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1
 /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/i386-redhat-
linux
 /usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/backward
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.0.1/include
 /usr/include
End of search list.
 /usr/libexec/gcc/i386-redhat-linux/4.0.1/cc1plus -fpreprocessed exp.ii -quiet 
-dumpbase exp.cpp -auxbase exp -Wall -version -o exp.s
GNU C++ version 4.0.1 20050727 (Red Hat 4.0.1-5) (i386-redhat-linux)
	compiled by GNU C version 4.0.1 20050727 (Red Hat 4.0.1-5).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-
heapsize=64417
exp.cpp: In function 'int main()':
exp.cpp:13: error: ambiguous overload for 'operator<<' in 'a << b'
exp.cpp:3: note: candidates are: void A::operator<<(T&) [with T = B<A>]
exp.cpp:7: note:                 void operator<<(A&, B<T>&) [with T = A]

# 1 "exp.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "exp.cpp"
struct A
{
    template<class T> void operator<<(T&);
};

template<class T> struct B {};
template<class T> void operator<<(A&, B<T>&);

int main()
{
    A a;
    B<A> b;
    a << b;
}

-- 
           Summary: overload resolution fails to select a more specialized
                    template
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: maxim dot yegorushkin at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
@ 2005-08-22 11:17 ` pinskia at gcc dot gnu dot org
  2005-08-26 15:02 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-22 11:17 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
      Known to fail|                            |4.0.2 4.1.0
      Known to work|                            |3.4.0
            Summary|overload resolution fails to|[4.0/4.1 Regression]
                   |select a more specialized   |overload resolution fails to
                   |template                    |select a more specialized
                   |                            |template
   Target Milestone|---                         |4.0.2


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
  2005-08-22 11:17 ` [Bug c++/23513] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-08-26 15:02 ` pinskia at gcc dot gnu dot org
  2005-08-27 21:51 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-26 15:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-26 15:01 -------
It started to fail after 20041211.

-- 


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
  2005-08-22 11:17 ` [Bug c++/23513] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
  2005-08-26 15:02 ` pinskia at gcc dot gnu dot org
@ 2005-08-27 21:51 ` mmitchel at gcc dot gnu dot org
  2005-09-15 21:19 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-08-27 21:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-08-27 21:49 -------
Nathan --

This change comes from:

2005-04-03  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.

I looked at DR124, but I didn't see anything to justify the "member functions
are unordered wrt non-mebers" claim.  What am I missing?

-- Mark

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at codesourcery dot
                   |                            |com


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
                   ` (2 preceding siblings ...)
  2005-08-27 21:51 ` mmitchel at gcc dot gnu dot org
@ 2005-09-15 21:19 ` mmitchel at gcc dot gnu dot org
  2005-09-16  7:30 ` nathan at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-15 21:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-09-15 21:19 -------
Nathan, do you have any insights about this PR?

-- 


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
                   ` (3 preceding siblings ...)
  2005-09-15 21:19 ` mmitchel at gcc dot gnu dot org
@ 2005-09-16  7:30 ` nathan at gcc dot gnu dot org
  2005-09-16 13:37 ` nathan at gcc dot gnu dot org
  2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-09-16  7:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2005-09-16 07:30 -------
I shall take a look

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |nathan at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-16 07:30:41
               date|                            |


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
                   ` (4 preceding siblings ...)
  2005-09-16  7:30 ` nathan at gcc dot gnu dot org
@ 2005-09-16 13:37 ` nathan at gcc dot gnu dot org
  2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: nathan at gcc dot gnu dot org @ 2005-09-16 13:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2005-09-16 13:37 -------
This is a piece of underspecification in the resolution of DR 214
(http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#214).  That
basically tells one to compare pairs of arguments.  But in this case we have a
member function and a non-member function -- how should we treat the this
pointer of the member function and the first arg of the non-member function?

As the algorithm did not give any indication as to how to order these, I made
them unordered.

Experimentation using the edg 3.6 frontend I find it to skip the first argument
of both functions (either an explicit arg or implicit this pointer) if either
function is a member function.  The alternative, of comparing the this pointer
arg with the explicit arg of the other function requires treating the this
pointer argument as-if it were a reference to the object (otherwise it'll never
deduce in either direction as the explicit argument must be a by-value or
by-reference object).  Experimentation shows the EDG front end does not take
that approach.


-- 


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


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

* [Bug c++/23513] [4.0/4.1 Regression] overload resolution fails to select a more specialized template
  2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
                   ` (5 preceding siblings ...)
  2005-09-16 13:37 ` nathan at gcc dot gnu dot org
@ 2005-09-27 16:21 ` mmitchel at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:21 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


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


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

end of thread, other threads:[~2005-09-27 16:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-22  9:48 [Bug c++/23513] New: overload resolution fails to select a more specialized template maxim dot yegorushkin at gmail dot com
2005-08-22 11:17 ` [Bug c++/23513] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-08-26 15:02 ` pinskia at gcc dot gnu dot org
2005-08-27 21:51 ` mmitchel at gcc dot gnu dot org
2005-09-15 21:19 ` mmitchel at gcc dot gnu dot org
2005-09-16  7:30 ` nathan at gcc dot gnu dot org
2005-09-16 13:37 ` nathan at gcc dot gnu dot org
2005-09-27 16:21 ` mmitchel 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).