Skip to content

Commit a27a685

Browse files
committed
[clang] Fix a crash in debug mode
Resolves Issue #35603 This bug was caused due to the assertions being too strict, loosened by stripping qualifiers from the base class but not from the type of the initializer. Added Release Notes for the same.
1 parent 0ca74c3 commit a27a685

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ Bug Fixes to C++ Support
268268
- Clang no longer tries to call consteval constructors at runtime when they appear in a member initializer.
269269
(`#782154 <https://github.com/llvm/llvm-project/issues/82154>`_`)
270270

271+
- Fix crash when inheriting from a cv-qualified type. Fixes:
272+
(`#35603 <https://github.com/llvm/llvm-project/issues/35603>`_)
273+
271274
Bug Fixes to AST Handling
272275
^^^^^^^^^^^^^^^^^^^^^^^^^
273276

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6421,7 +6421,7 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
64216421
// Non-virtual base classes are initialized in the order in the class
64226422
// definition. We have already checked for virtual base classes.
64236423
assert(!BaseIt->isVirtual() && "virtual base for literal type");
6424-
assert(Info.Ctx.hasSameType(BaseIt->getType(), BaseType) &&
6424+
assert(Info.Ctx.hasSameUnqualifiedType(BaseIt->getType(), BaseType) &&
64256425
"base class initializers not in expected order");
64266426
++BaseIt;
64276427
#endif

clang/test/Sema/GH70594.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2+
// RUN: %clang_cc1 -fsyntax-only -std=c++23 %s -verify
3+
4+
// expected-no-diagnostics
5+
6+
struct A {};
7+
using CA = const A;
8+
9+
struct S1 : CA {
10+
constexpr S1() : CA() {}
11+
};
12+
13+
struct S2 : A {
14+
constexpr S2() : CA() {}
15+
};
16+
17+
struct S3 : CA {
18+
constexpr S3() : A() {}
19+
};

0 commit comments

Comments
 (0)