Skip to content

[clang-tidy] Noisy cppcoreguidelines-narrowing-conversions warning for types subject to arithmetic conversion #111510

@chrchr-github

Description

@chrchr-github
void f(short& a, short b, short c) {
    a = b + c;
}
<source>:2:9: warning: narrowing conversion from 'int' to signed type 'short' is implementation-defined [bugprone-narrowing-conversions]
    2 |     a = b + c;
      |

https://godbolt.org/z/913zov7vz
Maybe there could be an option to suppress the warning in case all types involved are the same? I don't see how adding a cast would improve the example.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions