public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Zarathustra at gentlemansclub dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/30822] wrong choice of overloaded template functions in recursive call
Date: Fri, 09 Mar 2007 12:36:00 -0000	[thread overview]
Message-ID: <20070309123550.18105.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30822-14112@http.gcc.gnu.org/bugzilla/>



------- Comment #6 from Zarathustra at gentlemansclub dot de  2007-03-09 12:35 -------
(In reply to comment #5)
> So, the way I read this is that gcc3.3 and icc9.0 agree that the call is
> ambiguous. I must admit that I don't know whether this is the correct
> behavior.
Also the SunCC yields the ambiguity message. I think in all such cases the
compilers do not implement all rules for the look up of template names as given
by the standard. Probably starting from version 3.4.0 of gcc the error message
changes.

Perhaps it is worth taking a look at the following code:
One template argument is left away, and some "<>" are added.
foo2 is accepted, foo3 is not! From this I assume that there is some problem
with the implementation of the argument-dependent lookup (ADP) in gcc. Does
anyone have any other assumptions?

struct cons_end {};

template<typename U,typename V> struct cons {
 U elem;
 V tail;
};

template<typename U, typename V>
void foo2(U elem, V tail)
{
 foo2(tail.elem,tail.tail);
}

template<typename U>
void foo2(U elem, cons_end tail)
{}

template<typename U, typename V>
void foo3(U elem, V tail)
{
 foo3<>(tail.elem,tail.tail); // <-- the difference is here (<> added)
}

template<typename U>
void foo3(U elem, cons_end tail)
{}

int main()
{
 cons<int,cons<int,cons_end> > list;
 foo2(list.elem,list.tail);
 foo2<>(list.elem,list.tail);
 foo3(list.elem,list.tail);
}

The error message (from gcc 4.1.2 and gcc 4.3):
test_gccbug.cpp: In function "void foo3(U, V) [with U = int, V = cons_end]":
test_gccbug.cpp:32:   instantiated from "void foo3(U, V) [with U = int, V =
cons<int, cons_end>]"
test_gccbug.cpp:44:   instantiated from here
test_gccbug.cpp:32: error: "struct cons_end" has no member named "elem"
test_gccbug.cpp:32: error: "struct cons_end" has no member named "tail"

Volker


-- 


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


  parent reply	other threads:[~2007-03-09 12:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 12:09 [Bug c++/30822] New: " Zarathustra at gentlemansclub dot de
2007-02-16 15:47 ` [Bug c++/30822] " pinskia at gcc dot gnu dot org
2007-02-16 16:35 ` Zarathustra at gentlemansclub dot de
2007-02-21  7:44 ` Zarathustra at gentlemansclub dot de
2007-02-21 10:16 ` Zarathustra at gentlemansclub dot de
2007-03-09  4:14 ` bangerth at dealii dot org
2007-03-09 12:36 ` Zarathustra at gentlemansclub dot de [this message]
2007-05-17 12:27 ` Zarathustra at gentlemansclub dot de

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=20070309123550.18105.qmail@sourceware.org \
    --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).