-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang] Ensure zero-init is not overridden when initializing a base c…
…lass in a constant expression context (#70150) During constant evaluation when value-initializing a class if the base class was default-initialized it would undue the previously zero-initialized class members. This fixes the way we handle default initialization to avoid initializing over an already initialized member to an indeterminate value. Fixes: #69890
- Loading branch information
Showing
4 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
clang/test/CXX/dcl.decl/dcl.init/dcl.init.general/p16-cxx20.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s | ||
|
||
// If the initializer is (), the object is value-initialized. | ||
|
||
// expected-no-diagnostics | ||
namespace GH69890 { | ||
struct A { | ||
constexpr A() {} | ||
int x; | ||
}; | ||
|
||
struct B : A { | ||
int y; | ||
}; | ||
|
||
static_assert(B().x == 0); | ||
static_assert(B().y == 0); | ||
} |