[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Fri May 16 16:45:46 PDT 2025


ziqingluo-90 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

https://github.com/llvm/llvm-project/pull/101126


More information about the cfe-commits mailing list