This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50248] New: gcc confused, tries to use variadic template to copy itself when it should use default constructor
- From: "b.r.longbons at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 31 Aug 2011 09:23:39 +0000
- Subject: [Bug c++/50248] New: gcc confused, tries to use variadic template to copy itself when it should use default constructor
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50248
Bug #: 50248
Summary: gcc confused, tries to use variadic template to copy
itself when it should use default constructor
Classification: Unclassified
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: b.r.longbons@gmail.com
Created attachment 25149
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25149
far smaller example than the 30000 lines where I first encountered the bug
GCC is trying to instantiate the variadic template as if to copy itself, but
the only thing it should be doing is calling the default constructor.
It only happens when it is constexpr and uses rvalue references.
It only happens when it the parent class has a deleted copy constructor that
takes a *nonconst* reference.
4.5.3 compiles it, but that's because it actually ignores the constexpr
keyword.
Known bad: 4.6.0, 4.6.1-4 debian, svn trunk as of 20110804
Workarounds:
1. Don't use rvalue references.
2. Add a fixed parameter before the variadic one.
Error message:
bug.cpp: In constructor 'constexpr earray<Elt, max>::earray(Elt2&& ...) [with
Elt2 = {earray<short int, 11u>&}, Elt = short int, unsigned int max = 11u]':
bug.cpp:25:30: instantiated from here
bug.cpp:9:50: error: cannot convert 'earray<short int, 11u>' to 'short int' in
initialization
bug.cpp:9: confused by earlier errors, bailing out