Skip to content

Commit 335e00f

Browse files
committed
[clang][Interp][NFC] Add another union test case
1 parent 951b13d commit 335e00f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clang/test/AST/Interp/unions.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,16 @@ constexpr A ab = {.d = 1.0};
3030
static_assert(ab.d == 1.0, "");
3131
static_assert(ab.a == 1, ""); // both-error {{not an integral constant expression}} \
3232
// both-note {{read of member 'a' of union with active member 'd'}}
33+
34+
namespace SimpleStore {
35+
union A {
36+
int a;
37+
int b;
38+
};
39+
constexpr int foo() {
40+
A a{.b = 4};
41+
a.b = 10;
42+
return a.b;
43+
}
44+
static_assert(foo() == 10, "");
45+
}

0 commit comments

Comments
 (0)