Consider this code:
struct S { int x; double y = 1.1; }; int main() { S s = {0}; }
In accordance with C ++ 14, ยง 8.5.1 / 7
If there are fewer initializer sentences in the list than in the aggregate, then each member that is not explicitly initialized should be initialized from its element with an equal-equal-initializer or, if there are no brackets or equal, an initializer from an empty initializer list (8.5.4) .
the code should be completely correct.
However, g ++ 4.9.2 rejects the code (compiled with -std=c++14 )
so.cpp:9:13: error: could not convert '{0}' from '<brace-enclosed initializer list>' to 'S' S s = {0};
clang ++ on the other hand compiles it.
Is this a known issue for g ++?
c ++ g ++ c ++ 14
vsoftco Jan 23 '15 at 15:57 2015-01-23 15:57
source share