public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "igodard at pacbell dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/24847] New: Instantiates un-called copy constructor Date: Mon, 14 Nov 2005 14:06:00 -0000 [thread overview] Message-ID: <bug-24847-6594@http.gcc.gnu.org/bugzilla/> (raw) enum A{b,c}; template<typename T, int i, A x> struct foo { explicit foo(T& t); explicit foo(foo<T, 0, x>); }; int main() { int i; foo<int, 5, b> v(i); } gets you: ~/ootbc/members/src$ g++ foo.cc foo.cc: In instantiation of `foo<int, 0, b>': foo.cc:10: instantiated from here foo.cc:5: error: invalid constructor; you probably meant `foo<int, 0, b> (const foo<int, 0, b>&)' The error arises because it thinks I am instantiating "foo<T, 0,A>(foo<T, 0, A>)", i.e. a copy constructor that is not taking a const reference argument. But I'm not; I'm instantiating the plain constructor "foo<T, int, A>(int&)". The second constructor is intended to catch the case: "foo<T, 5, A>(foo<T, 0, A>", i.e. to convert an instance of foo with second argument zero to a foo with any other second argument. It looks like when it is expanding the argument type of the second constructor (i.e. "foo<T, 0, A>") that it is not just parsing the resulting template but also applying the "valid copy constructor?" check for that type. But as that second constructor is never called by anyone it the compiler should just syntax check it (valid) and not semantic check it (invalid for "foo(T, 0, A)" but valid for everything else). Ivan -- Summary: Instantiates un-called copy constructor Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: igodard at pacbell dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24847
next reply other threads:[~2005-11-14 14:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-11-14 14:06 igodard at pacbell dot net [this message] 2005-11-14 19:32 ` [Bug c++/24847] " pinskia at gcc dot gnu dot org 2005-11-15 0:30 ` igodard at pacbell dot net 2005-11-23 5:21 ` bangerth at dealii 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=bug-24847-6594@http.gcc.gnu.org/bugzilla/ \ --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: 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).