[clang] Add tests for CWG issues 6, 212, 232, 2823. (PR #165633)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 18 17:46:42 PST 2025


================
@@ -61,6 +61,24 @@ namespace cwg2819 { // cwg2819: 19 c++26
 #endif
 } // namespace cwg2819
 
+namespace cwg2823 { // cwg2823: no
+#if __cplusplus >= 201103L
+  constexpr int *p = 0;
+  constexpr int *q1 = &*p;
----------------
zygoloid wrote:

Agreed, the examples here are all valid in C and all invalid in C++, due to C [6.5.3.2](https://www.iso-9899.info/n3047.html#6.5.3.2)/3:

> 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. 

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


More information about the cfe-commits mailing list