C++20 Designated Initializers - Multiple initializations of same struct member · Issue #47037 · llvm/llvm-project (original) (raw)

Bugzilla Link 47693
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

Hi,

I believe Clang shouldn't compile the code below with -std=c++20.

struct X { int a; };

int main() { X x{.a = 0, .a = 1}; return 0; }

GCC fails to compile it with the error:

error: '.a' designator used multiple times in the same initializer list
   14 |     X x{.a = 0, .a = 1};

Clang trunk successfully compiles the example.