Re: [cfe-users] -Wconversion does not produce warnings when it should

2020-11-16 Thread Marshall Clow via cfe-users
> On Nov 16, 2020, at 6:42 PM, David Blaikie via cfe-users > wrote: > > On Mon, Nov 16, 2020 at 4:49 PM Sven Köhler via cfe-users > mailto:cfe-users@lists.llvm.org>> wrote: >> >> Am 16.11.20 um 21:49 schrieb David Blaikie via cfe-users: >>> On Mon, Nov 16, 2020 at 12:36 PM Sven Köhler via cfe

Re: [cfe-users] -Wconversion does not produce warnings when it should

2020-11-16 Thread David Blaikie via cfe-users
On Mon, Nov 16, 2020 at 4:49 PM Sven Köhler via cfe-users wrote: > > Am 16.11.20 um 21:49 schrieb David Blaikie via cfe-users: > > On Mon, Nov 16, 2020 at 12:36 PM Sven Köhler via cfe-users > > wrote: > >> > >> Can you elaborate what is happening here? > > > > I believe/would guess the goal is to

Re: [cfe-users] -Wconversion does not produce warnings when it should

2020-11-16 Thread Sven Köhler via cfe-users
Am 16.11.20 um 21:49 schrieb David Blaikie via cfe-users: > On Mon, Nov 16, 2020 at 12:36 PM Sven Köhler via cfe-users > wrote: >> >> Can you elaborate what is happening here? > > I believe/would guess the goal is to reduce false positives (where a > false positive is defined as "warning on code

Re: [cfe-users] -Wconversion does not produce warnings when it should

2020-11-16 Thread David Blaikie via cfe-users
On Mon, Nov 16, 2020 at 12:36 PM Sven Köhler via cfe-users wrote: > > Hi, > > consider the following code: > > uint16_t testa4(uint8_t x, uint8_t y) { > return ( (uint16_t)x << 0 ) > | ( (uint16_t)y << 8 ); > } > uint16_t testb3(uint16_t x, uint16_t y) { > return x|y; > } > uin

Re: [cfe-users] -Wconversion does not produce warnings when it should

2020-11-16 Thread Sven Köhler via cfe-users
Hi, > even though the two operands of the bitwise-or are both uint16_t. That's not true. I had many more versions of the test code before I posted here and I got confused. In testa4, the operands of the bitwise-or are both ints due to the bitshift which performs and integer promotion. Kind Rega

[cfe-users] -Wconversion does not produce warnings when it should

2020-11-16 Thread Sven Köhler via cfe-users
Hi, consider the following code: uint16_t testa4(uint8_t x, uint8_t y) { return ( (uint16_t)x << 0 ) | ( (uint16_t)y << 8 ); } uint16_t testb3(uint16_t x, uint16_t y) { return x|y; } uint16_t testb4(uint16_t x, uint16_t y) { return x+y; } int testb4x(uint16_t x, uint16_t y