[Bug c++/80804] New: Default constructor improperly invoked in C++1z mode
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed May 17 13:58:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80804
Bug ID: 80804
Summary: Default constructor improperly invoked in C++1z mode
Product: gcc
Version: 7.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
>From StackOverflow (http://stackoverflow.com/q/44015848/2069064), this code:
#include <cstdio>
#include <initializer_list>
struct S {
S() { std::printf("DEF "); } // (1)
S(std::initializer_list<int> il) // (2)
{ std::printf("L=%zu ", il.size()); }
};
int main() {
S x({});
}
in gcc 7.1 with -std=c++1z invokes the default constructor. In C++14 mode, it
invokes the initializer_list constructor, as does clang in both modes. But the
default constructor shouldn't be invoked, since {} isn't an expression so the
"guaranteed elision" bullet in dcl.init shouldn't apply.
More information about the Gcc-bugs
mailing list