public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> To: gdr@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c++/99: [2003-03-26] Bug in type in error message. Date: Tue, 06 May 2003 13:06:00 -0000 [thread overview] Message-ID: <20030506130601.28339.qmail@sources.redhat.com> (raw) The following reply was made to PR c++/99; it has been noted by GNATS. From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de> To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, carlo@alinoe.com, gdr@gcc.gnu.org, gcc-prs@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de Cc: Subject: Re: c++/99: [2003-03-26] Bug in type in error message. Date: Tue, 6 May 2003 15:04:23 +0200 Here's a further reduced testcase, along with some more analysis: template<typename S> class X {}; template<typename Q> int f(X<int>, X<Q>); template<typename B> int f(X<B>, X<int>); int main(void) { return f(X<int>(), X<int>()); } If compiled this will output the following error message (note Q instead of B in the last line): 99-3.cc: In function `int main()': 99-3.cc:6: call of overloaded `f(X<int>, X<int>)' is ambiguous 99-3.cc:2: candidates are: int f(X<int>, X<Q>) [with Q = int] 99-3.cc:3: int f(X<Q>, X<int>) [with B = int] Analysis: When instantiating X<Q> a typedef like construct is created an added the list of instantiations of X. Should we ever ancounter X<Q> again, this type will be reused an no new instantiation is created. We also note along with the type that the template parameter S is bound to the outer template parameter Q. The relevant code for this is in pt.c:lookup_template_class. Problem: When we need to find a type for X<B> in a completly different outer template we walk the list of instantiations again (line 4322) and come accross the instance of X<Q>. At this point gcc (wrongly) decides that the Q in X<Q> and B are the same template parameters and reuses X<Q> instead of creating a new type. This can happen because there is no check if we're still in the same outer template. There are only checks if TEMPLATE_TYPE_IDX and TEMPLATE_TYPE_LEVEL match. However, the context of TEMPLATE_TYPE_DECLs should be compared somehow as well. regards Christian -- THAT'S ALL FOLKS!
reply other threads:[~2003-05-06 13:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20030506130601.28339.qmail@sources.redhat.com \ --to=ehrhardt@mathematik.uni-ulm.de \ --cc=gcc-prs@gcc.gnu.org \ --cc=gdr@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).