Skip to content

Commit

Permalink
[clang][Interp][NFC] Add another union test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed May 23, 2024
1 parent 951b13d commit 335e00f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions clang/test/AST/Interp/unions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@ constexpr A ab = {.d = 1.0};
static_assert(ab.d == 1.0, "");
static_assert(ab.a == 1, ""); // both-error {{not an integral constant expression}} \
// both-note {{read of member 'a' of union with active member 'd'}}

namespace SimpleStore {
union A {
int a;
int b;
};
constexpr int foo() {
A a{.b = 4};
a.b = 10;
return a.b;
}
static_assert(foo() == 10, "");
}

0 comments on commit 335e00f

Please sign in to comment.