[Bug c++/78551] New: Internal compiler error with constexpr initialization of union
vlad at petric dot cc
gcc-bugzilla@gcc.gnu.org
Sun Nov 27 17:18:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78551
Bug ID: 78551
Summary: Internal compiler error with constexpr initialization
of union
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vlad at petric dot cc
Target Milestone: ---
The following code ICEs:
#include <array>
#include <cinttypes>
struct A {
union {
uint64_t s;
char buff[8];
};
constexpr A(const char* str) : s(0) {
if (str == nullptr) return;
size_t i = 0;
for (; i < 8 && str[i] != '\0'; ++i) {
buff[i] = str[i];
}
if (str[i] != '\0') throw std::out_of_range("");
}
};
constexpr std::array<A, 2> array({"long", "longer"});
It doesn't ICE if I do any of the following:
1. Switch the constructor to char[N] (where N is from template<size_t N>)
2. Get rid of constexpr
3. Get rid of the union - just initialize buff
More information about the Gcc-bugs
mailing list