https://bugs.llvm.org/show_bug.cgi?id=40030

            Bug ID: 40030
           Summary: Designated initialisers - diagnose invalid designator
                    order in C++20
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

struct S
{
    int number;
    const char *s;
};

S f()
{
    return S{.number = 0, .s = "hi}; // correct order
    return S{.s = "hi",  .number = 0}; // invalid (out of) order
}

This should not be allowed in C++20 (according to a C++2a standard) and GCC
does not compile it - Clang trunk allows it.

GCC:
error: designator order for field 'S::number' does not match declaration order
in 'S'
   12 |     return S{.s = "hi",  .number = 0};

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to