Skip to content

Commit 7e14846

Browse files
committed
fix
1 parent 9cb9a97 commit 7e14846

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ Bug Fixes to C++ Support
967967
- Fixed an assertion failure about invalid conversion when calling lambda. (#GH96205).
968968
- Fixed a bug where the first operand of binary ``operator&`` would be transformed as if it was the operand
969969
of the address of operator. (#GH97483).
970+
- Fixed an assertion failure about constant expression did not evaluate to integer. (#GH96670).
970971

971972
Bug Fixes to AST Handling
972973
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15858,7 +15858,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result,
1585815858
}
1585915859

1586015860
if (const auto *CE = dyn_cast<ConstantExpr>(Exp)) {
15861-
if (CE->hasAPValueResult()) {
15861+
if (CE->hasAPValueResult() && !CE->getAPValueResult().isLValue()) {
1586215862
Result.Val = CE->getAPValueResult();
1586315863
IsConst = true;
1586415864
return true;

clang/test/SemaCXX/eval-crashes.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ struct array {
6161
array() : data(*new int[1][2]) {}
6262
};
6363
}
64+
65+
namespace GH96670 {
66+
inline constexpr long ullNil = -1;
67+
68+
template<typename T = long, const T &Nil = ullNil>
69+
struct Test {};
70+
71+
inline constexpr long lNil = -1;
72+
Test<long, lNil> c;
73+
}

0 commit comments

Comments
 (0)