Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Invalid consteval constructor invocation does not cause an error #51593

Closed
Assignees
usx95
Labels
accepts-invalidbugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyconstevalC++20 consteval
@stbergmann

Description

@stbergmann
Bugzilla Link52251
Versiontrunk
OSLinux
CC@AaronBallman,@zygoloid

Extended Description

At least with Clang 13 and recent Clang 14 trunk,

$ cat test.cc
struct S {
consteval S() {}
int a;
};
S s2;

$ clang++ -std=c++20 -fsyntax-only test.cc

erroneously succeeds, while e.g. with GCC 11 it fails with

$ g++ -std=c++20 -fsyntax-only test.cc
test.cc:5:3: error: ‘S()’ is not a constant expression
5 | S s2;
| ^~
test.cc:5:3: error: ‘s2.S::S()’ is not a constant expression because it refers to an incompletely initialized variable

(I think this is different from bug 51560, as the initialization of s2 here asks for default-initialization via the S() constructor.)

Metadata

Metadata

Assignees

Labels

accepts-invalidbugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyconstevalC++20 consteval

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp