Skip to content

C++20 Designated Initializers - Nested initialization #47039

@llvmbot

Description

@llvmbot
Bugzilla Link 47694
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @pogo59,@zygoloid

Extended Description

Hi,

This code snippet is taken from P0329R4.

struct A
{
    int x;
};

struct B
{
    A a;
};

int main()
{
    B b{.a.x = 0};
    return 0;
}

GCC fails to compile this example, which should be invalid according to the C++20 standard.

GCC error:

error: expected primary-expression before '.' token
   13 |     B b{.a.x = 0};

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions