[llvm-bugs] [Bug 43921] New: Rejects valid: reading of an inactive union member that shares common initial sequence with the active one
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 6 09:21:59 PST 2019
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: unassignedclangbugs at nondot.org
Reporter: nok.raven at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191106/d96a5fd2/attachment.html>
More information about the llvm-bugs
mailing list