https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68739
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
OK, so we get:
struct pthread_mutex {
short m_short[2];
int m_int;
int m_int1[4];
void *m_ptr;
int m_int2[2];
int m_int3[4];
short m_short2[2];
int m_int4[5];
int m_int5[2];
};
struct M {
pthread_mutex m = { 0x36, 0, (0x80 | 0x1), 1, 1, 1, 1, ((void *) 1LL), 1, 0, 0,
0, -1, 0, 0, 2368, 0, 1, 1, 1, 1, 0, 0 };
};
constexpr M m;
Which gives the unhelpful error:
pt.cc:17:13: error: ‘constexpr M::M()’ called in a constant expression
constexpr M m;
^
pt.cc:13:8: note: ‘constexpr M::M()’ is not usable as a constexpr function
because:
struct M {
^
(I'll report that as a front-end bug).
I think the (void*) 1LL is the problem, you can't do a reinterpret_cast in a
constant expression.
This gives the same error:
struct pthread_mutex {
void *m_ptr;
};
struct M {
pthread_mutex m = { ((void *) 1LL) };
};
constexpr M m;