Open llvmbot opened 4 years ago
... actually, the store in comment#1 is clearly bogus: the type being stored is different from the type of the destination pointer. (I'm a little surprised that doesn't fail the verifier.)
This version crashes in Clang's IR generation instead, but only when using libstdc++ (with libc++ it crashes in InstCombine like the other testcases): https://godbolt.org/z/xzK9Pr
Reduced:
template<typename T, typename U>
struct variant {
union { T t; U u; };
constexpr variant(T t) : t(t) {}
constexpr U &get() { return u; }
};
struct Sum {};
struct Value {
int value;
};
consteval auto foo() {
variant<Sum, Value> result = Sum{};
return result;
}
int main() {
auto result = foo();
return result.get().value;
}
The generated IR (https://godbolt.org/z/vq4jhq) looks OK to me; the only slightly unusual thing here is an FCA store of undef
:
store { %struct.Sum, [3 x i8] } undef, %union.anon* %4, align 4
Extended Description
Works in clang-10.0.1 but not in clang trunk.
code example: https://godbolt.org/z/j4bGxx
Furthermore this slight variation works: https://godbolt.org/z/beMvE9