Issue 168707
Summary Incorrect handling of &* in constexpr in C23
Labels c23, clang:frontend, constexpr, regression:21
Assignees
Reporter AaronBallman
    Consider:
```
void f() {
  constexpr int *p = 0;
  constexpr int *q1 = &*p;
}
```
this is invalid in C++, but should be valid in C per 6.5.3.2p3:
> The unary & operator yields the address of its operand. If the operand has type "type", the result has
type "pointer to type". If the operand is the result of a unary * operator, neither that operator nor
the & operator is evaluated and the result is as if both were omitted, except that the constraints on
the operators still apply and the result is not an lvalue. Similarly, if the operand is the result of a []
operator, neither the & operator nor the unary * that is implied by the [] is evaluated and the result
is as if the & operator were removed and the [] operator were changed to a + operator.

Clang rejects, GCC accepts: https://godbolt.org/z/oW14TEa9P

This is a recent regression, Clang 21 accepts but trunk rejects,
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to