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

--- Comment #3 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
Here is a better example. It looks valid (unlike above one) because of creating
of copy `A( u.a )`:
```
#include <iostream>

struct A { int c[7]; };

struct X { int x; };

struct B : X, A {
    using A::operator=;
};

int main() {
    union U {
        A a{ 0, 1, 2, 3, 4, 5, 6 };
        B b;
    } u;

    u.b = A( u.a );

    for ( int i = 0; i < 7; ++i )
        std::cout << (int)u.b.c[i];
}
```

It prints `0123456` in Clang and MSVC. But in GCC 14 it prints `0122356` with
any optimization level (-O0 through -O3). Online demo:
https://gcc.godbolt.org/z/GKo8YcqqM

Reply via email to