File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -859,6 +859,8 @@ Bug Fixes to C++ Support
859
859
(#GH88081), (#GH89496), (#GH90669) and (#GH91633).
860
860
- Fixed handling of brace ellison when building deduction guides. (#GH64625), (#GH83368).
861
861
- Clang now instantiates local constexpr functions eagerly for constant evaluators. (#GH35052), (#GH94849)
862
+ - Fixed a failed assertion when attempting to convert an integer representing the difference
863
+ between the addresses of two labels (a GNU extension) to a pointer within a constant expression. (#GH95366).
862
864
863
865
Bug Fixes to AST Handling
864
866
^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -9325,6 +9325,13 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
9325
9325
Result.IsNullPtr = false;
9326
9326
return true;
9327
9327
} else {
9328
+ // In rare instances, the value isn't an lvalue.
9329
+ // For example, when the value is the difference between the addresses of
9330
+ // two labels. We reject that as a constant expression because we can't
9331
+ // compute a valid offset to convert into a pointer.
9332
+ if (!Value.isLValue())
9333
+ return false;
9334
+
9328
9335
// Cast is of an lvalue, no need to change value.
9329
9336
Result.setFrom(Info.Ctx, Value);
9330
9337
return true;
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
2
+
3
+ int x (void ) { e : b : ; return & & e - & & b < x ; } // expected-warning {{ordered comparison between pointer and integer}}
You can’t perform that action at this time.
0 commit comments