public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "maxim dot yegorushkin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/23513] New: overload resolution fails to select a more specialized template
Date: Mon, 22 Aug 2005 09:48:00 -0000	[thread overview]
Message-ID: <20050822093824.23513.maxim.yegorushkin@gmail.com> (raw)

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


             reply	other threads:[~2005-08-22  9:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-22  9:48 maxim dot yegorushkin at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050822093824.23513.maxim.yegorushkin@gmail.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).