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

            Bug ID: 125644
           Summary: narrowing warnings emitted twice
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ivan.lazaric.gcc at gmail dot com
  Target Milestone: ---

```cpp
#include <vector>

void fn(auto... args) {
    std::vector<std::size_t>{args...};
}

int main() {
    fn(3, 3);
}
```

Compiler flags: "-std=c++26" (-Wnarrowing is defaulted)

Compiler diagnostics:
```
<source>: In instantiation of 'void fn(auto:6 ...) [with auto:6 = {int, int}]':
<source>:8:7:   required from here
    8 |     fn(3, 3);
      |     ~~^~~~~~
<source>:4:30: warning: narrowing conversion of 'args#0' from 'int' to 'long
unsigned int' [-Wnarrowing]
    4 |     std::vector<std::size_t>{args...};
      |                              ^~~~
<source>:4:30: warning: narrowing conversion of 'args#0' from 'int' to 'long
unsigned int' [-Wnarrowing]
<source>:4:30: warning: narrowing conversion of 'args#1' from 'int' to 'long
unsigned int' [-Wnarrowing]
<source>:4:30: warning: narrowing conversion of 'args#1' from 'int' to 'long
unsigned int' [-Wnarrowing]
Compiler returned: 0
```

Compiler emitted two warnings for each member of the parameter pack,
a single warning per suffices.
In this specific case no warning would also be fine IMO since `3`
is representable in both `int` and `long unsigned int` exactly.

Godbolt: https://godbolt.org/z/7bTGvjGfz

Reply via email to