Skip to content

Commit 864bd0e

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 8e8c954 commit 864bd0e

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
@@ -918,6 +918,9 @@ Bug Fixes to C++ Support
918918
(`#57410 <https://github.com/llvm/llvm-project/issues/57410>`_) and
919919
(`#76604 <https://github.com/llvm/llvm-project/issues/57410>`_)
920920

921+
- Fix crash when inheriting from a cv-qualified type. Fixes:
922+
(`#35603 <https://github.com/llvm/llvm-project/issues/35603>`_)
923+
921924
Bug Fixes to AST Handling
922925
^^^^^^^^^^^^^^^^^^^^^^^^^
923926
- Fixed an import failure of recursive friend class template.

clang/lib/AST/ExprConstant.cpp

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

clang/test/Sema/GH35603.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)