public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Giovanni Bajo" <giovannibajo@libero.it> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c++/10394: type inference gets confused during template instantiation Date: Mon, 14 Apr 2003 01:26:00 -0000 [thread overview] Message-ID: <20030414012601.26382.qmail@sources.redhat.com> (raw) The following reply was made to PR c++/10394; it has been noted by GNATS. From: "Giovanni Bajo" <giovannibajo@libero.it> To: <colby@alum.mit.edu>, <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <nobody@gcc.gnu.org>, <gcc-prs@gcc.gnu.org> Cc: "Wolfgang Bangerth" <bangerth@ices.utexas.edu> Subject: Re: c++/10394: type inference gets confused during template instantiation Date: Mon, 14 Apr 2003 03:24:12 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p r=10394 Your code is ill-formed, and correctly rejected by any GCC version I have (even if the error message could use a lifting). To invoke correctly the function, you have to use this syntax: a.f(typename A<typename V::X>::template B<int>()); Because: - B<> is a nested template within A<>. A<> is dependent on C's template parameter, so the keyword 'template' is needed in front of it to disambiguate the parser. - The whole expression A<typename V::X>::template B<int> refers to a type name, which is dependent on C's template paremter, so the keyword 'typename' is needed in front of it to disambiguate the parser. Your line marked as [1] compiles because it is a function declaration, not an object instantiation. Specifically, you're declaring a function called "c" which returns an object of type C<E>, and accepts as parameter a pointer to a function which gets no parameters and returns a A<int>. Nonetheless, I found a regression on the mainline while playing with this: ------------------------------------------------------- template <class T> struct A { template <class U> class B {}; }; template <class V> struct C { C() { A<typename V::X>::template B<int> k; } }; struct E { typedef int X; }; template struct C<E>; int main() {} ------------------------------------------------------- pr10394.cpp: In constructor `C<V>::C()': pr10394.cpp:13: error: expected `;' pr10394.cpp: In constructor `C<V>::C() [with V = E]': pr10394.cpp:22: instantiated from here pr10394.cpp:13: internal compiler error: in resolve_offset_ref, at cp/init.c: 1841 Please submit a full bug report, on 3.4 20030413. Since the code is ill-formed (missing 'typename' keyword at the start of the definition of k), this is a 3.4 regression, ice-on-illegal-code. Previous versions (2.95 -> 3.3) reports some kind of (unreadable) error message at least. Giovanni Bajo
next reply other threads:[~2003-04-14 1:26 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-04-14 1:26 Giovanni Bajo [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-04-14 12:00 ehrhardt 2003-04-13 21:36 colby
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=20030414012601.26382.qmail@sources.redhat.com \ --to=giovannibajo@libero.it \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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: linkBe 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).