forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Allow class with anonymous union member to be const-default-c…
…onstructible even if a union member has a default member initializer (llvm#95854) Resolves llvm#95854 Clang incorrectly considers a class with an anonymous union member to not be const-default-constructible even if a union member has a default member initializer. ``` struct A { union { int n = 0; int m; }; }; const A a; ``` -- As per https://eel.is/c++draft/dcl.init#general-8.3
- Loading branch information
1 parent
64d9713
commit b46a96d
Showing
4 changed files
with
33 additions
and
3 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
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,19 @@ | ||
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s | ||
|
||
struct A { | ||
union { | ||
int n = 0; | ||
int m; | ||
}; | ||
}; | ||
const A a; | ||
|
||
struct B { | ||
union { | ||
struct { | ||
int n = 5; | ||
int m; | ||
}; | ||
}; | ||
}; | ||
const B b; // expected-error {{default initialization of an object of const type 'const B' without a user-provided default constructor}} |