File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -9237,9 +9237,10 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
9237
9237
bool HasValidResult = !Result.InvalidBase && !Result.Designator.Invalid &&
9238
9238
!Result.IsNullPtr;
9239
9239
bool VoidPtrCastMaybeOK =
9240
- HasValidResult &&
9241
- Info.Ctx.hasSameUnqualifiedType(Result.Designator.getType(Info.Ctx),
9242
- E->getType()->getPointeeType());
9240
+ Result.IsNullPtr ||
9241
+ (HasValidResult &&
9242
+ Info.Ctx.hasSimilarType(Result.Designator.getType(Info.Ctx),
9243
+ E->getType()->getPointeeType()));
9243
9244
// 1. We'll allow it in std::allocator::allocate, and anything which that
9244
9245
// calls.
9245
9246
// 2. HACK 2022-03-28: Work around an issue with libstdc++'s
Original file line number Diff line number Diff line change 10
10
// expected-no-diagnostics
11
11
#endif
12
12
13
+ namespace cwg2819 { // cwg2819: 19 review 2023-12-01
14
+ #if __cpp_constexpr >= 202306L
15
+ constexpr void * p = nullptr ;
16
+ constexpr int * q = static_cast <int *>(p);
17
+ static_assert (q == nullptr );
18
+ #endif
19
+ }
20
+
13
21
namespace cwg2847 { // cwg2847: 19
14
22
15
23
#if __cplusplus >= 202002L
Original file line number Diff line number Diff line change @@ -37,3 +37,10 @@ void err() {
37
37
// cxx23-note {{cast from 'void *' is not allowed in a constant expression in C++ standards before C++2c}} \
38
38
// cxx26-note {{cast from 'void *' is not allowed in a constant expression because the pointed object type 'T' is not similar to the target type 'S'}}
39
39
}
40
+
41
+ int * p;
42
+ constexpr int ** pp = &p;
43
+ constexpr void * vp = pp;
44
+ constexpr auto cvp = static_cast <const int * volatile *>(vp);
45
+ // cxx23-error@-1 {{constant expression}}
46
+ // cxx23-note@-2 {{cast from 'void *' is not allowed in a constant expression}}
Original file line number Diff line number Diff line change @@ -16722,7 +16722,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
16722
16722
<td><a href="https://cplusplus.github.io/CWG/issues/2819.html">2819</a></td>
16723
16723
<td>review</td>
16724
16724
<td>Cast from null pointer value in a constant expression</td>
16725
- <td align="center">Not resolved </td>
16725
+ <td title="Clang 19 implements 2023-12-01 resolution" align="center">Not Resolved* </td>
16726
16726
</tr>
16727
16727
<tr class="open" id="2820">
16728
16728
<td><a href="https://cplusplus.github.io/CWG/issues/2820.html">2820</a></td>
You can’t perform that action at this time.
0 commit comments