[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon May 19 05:03:19 PDT 2025
AaronBallman wrote:
> ```
> typedef __attribute__((__ext_vector_type__(2))) float float2;
>
> struct vec2 {
> float2 _v;
> public:
> constexpr vec2(float x, float y) {
> _v.x = x;
> _v.y = y;
> }
> };
>
> constexpr struct vec2 f() {
> return vec2(1.0, 1.0);
> }
>
> int main() {
> vec2 S = f();
> }
> ```
>
> Clang crashes: https://godbolt.org/z/sx74s1bqd
Can confirm the crash is happening. The issue is related to the constructor being `constexpr` and not initializing the member variable. If you use a member initializer list, the assert is silenced: https://godbolt.org/z/vEbeb4jbz
Can you file an issue so we don't lose track of the bug? Also @vikramRH any chance you can look into this?
https://github.com/llvm/llvm-project/pull/101126
More information about the cfe-commits
mailing list