llvm / llvm/llvm-project

Clang rejects conditional operator on GNU vectors in constant expressions

Open
#213,278 2 comments 0 reactions 0 assignees View on GitHub
clang:frontend constexpr diverges-from:gcc libstdc++
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

[Test case](https://compiler-explorer.com/z/68GEcjrE8):

```c++
using V [[gnu::vector_size(16)]] = int;
constexpr V x = V() == V() ? V() : V();
```

There is no reason to not support the conditional operator in constant expressions of GNU vector types if all the other operators are supported. And, obviously, this issue blocks the use of libstdc++'s std::simd implementation.

Contributor guide

Open the contributing guide

Research direction

Start with the Compiler Explorer test case linked in the issue and reproduce the constexpr failure for the GNU vector conditional expression. Trace Clang's handling of constant expressions and GNU vector operators, then add coverage showing that the expression is accepted while preserving the expected behavior for unsupported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.