Issue 162658
Summary `-Wextra` demotes `-Winitializer-overrides` from error to warning even when `-pedantic-errors` is present
Labels clang:diagnostics
Assignees
Reporter HolyBlackCat
    ```cpp
struct A
{
    int a;
};

A a{
    .a = 10,
    .a = 20,
};
```
This correctly errors with `-std=c++20 -pedantic-errors`:
```console
<source>:8:10: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
 8 |     .a = 20,
      |          ^~
<source>:7:10: note: previous initialization is here
    7 |     .a = 10,
      |          ^~
```

But if I use `-std=c++20 -pedantic-errors -Wextra`, this instead becomes a warning:
```console
<source>:8:10: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides]
    8 |     .a = 20,
      |          ^~
<source>:7:10: note: previous initialization is here
    7 |     .a = 10,
      |          ^~
```
I get the same warning if I use just `-std=c++20`.

The correct behavior is for this to be an error if `-pedantic-errors` is present, regardless of `-Wextra`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to