Gavrilov Vladimir reported the following issue in a direct email to gcc-bugs: markus@x4 tmp % cat map_bitfield.cpp #include <map> struct A { int i : 1; }; std::map<int, A> ma{{1, {0}}}; markus@x4 tmp % g++ -c map_bitfield.cpp map_bitfield.cpp:5:30: error: invalid initial value for member ‘i’ std::map<int, A> ma{{1, {0}}}; ^ GCC-5 and other compilers accept this code. A bit further reduced: markus@x4 tmp % cat map_bitfield2.cpp #include <initializer_list> template <typename T> struct A { A(std::initializer_list<T>); }; struct B { int k : 1; }; A<B> a{{0}}; markus@x4 tmp % g++ -c map_bitfield2.cpp map_bitfield2.cpp:6:12: error: invalid initial value for member ‘k’ A<B> a{{0}}; ^
Started with r230365. Testcase without any headers: namespace std { template <class T> struct initializer_list { const T *a; __SIZE_TYPE__ b; constexpr initializer_list (const T *x, __SIZE_TYPE__ y) : a(x), b(y) { } }; } template <typename T> struct A { A (std::initializer_list<T>); }; struct B { int k : 1; }; A<B> a{{0}};
Author: nathan Date: Fri Dec 9 12:18:36 2016 New Revision: 243479 URL: https://gcc.gnu.org/viewcvs?rev=243479&root=gcc&view=rev Log: PR c++/78550 * convert.c (convert_to_integer_1): Maybe fold conversions to integral types with fewer bits than its mode. testsuite/ PR c++/78550 * g++.dg/cpp1y/pr78550.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp1y/pr78550.C Modified: trunk/gcc/ChangeLog trunk/gcc/convert.c trunk/gcc/testsuite/ChangeLog
Author: nathan Date: Fri Dec 9 14:04:53 2016 New Revision: 243484 URL: https://gcc.gnu.org/viewcvs?rev=243484&root=gcc&view=rev Log: PR c++/78550 * convert.c (convert_to_integer_1): Maybe fold conversions to integral types with fewer bits than its mode. testsuite/ PR c++/78550 * g++.dg/cpp1y/pr78550.C: New. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp1y/pr78550.C Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/convert.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed on trunk & 6 branches