https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71446

--- Comment #5 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Jakub Jelinek from comment #3)
> Well, before C++2a it is an extension, so outside of the C++ standard, and
> GCC has been implementing it as not allowing to skip any fields.

Not exactly. Outside of overload resolution, GCC does implement it as allowing
skipping of fields. Test case:

struct S {
    int a, b;
    bool equals(S other) const { return a == other.a && b == other.b; }
} s = {.a = 0, .b = 1};
int main() { return !s.equals({.b = 1}); }

This program should and does return 0, showing that {.b = 1} initialises the
second field, not the first.

Reply via email to