This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces
- From: "ville.voutilainen at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 14 Jun 2015 17:11:30 +0000
- Subject: [Bug c++/66537] New: An explicit default constructor is accepted when initializing from empty braces
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66537
Bug ID: 66537
Summary: An explicit default constructor is accepted when
initializing from empty braces
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ville.voutilainen at gmail dot com
CC: jason at redhat dot com
Target Milestone: ---
Test snippet:
struct Bob
{
explicit Bob() {}
};
Bob f()
{
return {}; // #1
}
void f2(Bob) {}
int main()
{
f2({}); // #2
}
gcc accepts both #1 and #2, clang rejects both.
I have submitted a patch that makes the standard library tag types
non-default-constructible, but an alternative solution to certain kinds
of ambiguity problems with tuple would be to make the tag types' default
constructors explicit rather than suppressing them. That doesn't currently
work because the front-end accepts initializations like in the example above.