https://bugs.llvm.org/show_bug.cgi?id=43921
Bug ID: 43921
Summary: Rejects valid: reading of an inactive union member
that shares common initial sequence with the active
one
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Keywords: compile-fail
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
The wording is in [class.union]/1 and [class.mem]/25.
[class.mem]/25 contains an example:
struct T1 { int a, b; };
struct T2 { int c; double d; };
union U { T1 t1; T2 t2; };
int f() {
U u = { { 1, 2 } }; // active member is t1
return u.t2.c; // OK, as if u.t1.a were nominated
}
Running this example in constexpr context, or just turning the `f` into a
constexpr function produces an error:
<source>:4:15: error: constexpr function never produces a constant expression
[-Winvalid-constexpr]
constexpr int f() {
^
<source>:6:10: note: read of member 't2' of union with active member 't1' is
not allowed in a constant expression
return u.t2.c; // OK, as if u.t1.a were nominated
^
1 errors generated.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs