GCC turns &~ into | due to undefined bit-shift without warning

2019-03-11 Thread Moritz Strübe
Hey, I have the following code: #include void LL_ADC_SetChannelSingleDiff(uint32_t * val, uint32_t Channel, uint32_t SingleDiff) {     *val = (*val & (~(Channel & 0x7U))) | ((Channel & 0x7U ) & (0x7U << (SingleDiff & 0x20U))); } void test(uint32_t * testvar) {     LL_ADC_SetCha

Re: GCC turns &~ into | due to undefined bit-shift without warning

2019-03-11 Thread Jakub Jelinek
On Mon, Mar 11, 2019 at 08:49:30AM +, Moritz Strübe wrote: > Considering that C11 6.5.7#3 ("If  the  value  of  the  right operand  > is  negative  or  is greater than or equal to the width of the promoted > left operand, the behavior is undefined.") is not very widely known, as > it "normal

Re: GCC turns &~ into | due to undefined bit-shift without warning

2019-03-11 Thread Moritz Strübe
On 11.03.2019 at 10:14 Jakub Jelinek wrote: > You could build with -fsanitize=undefined, that would tell you at runtime you > have undefined behavior in your code (if the SingleDiff has bit ever 0x20 > set). Yes, that helps. Unfortunately I'm on an embedded system, thus the code size increase is

Re: GCC turns &~ into | due to undefined bit-shift without warning

2019-03-11 Thread Jakub Jelinek
On Mon, Mar 11, 2019 at 11:06:37AM +, Moritz Strübe wrote: > On 11.03.2019 at 10:14 Jakub Jelinek wrote: > > You could build with -fsanitize=undefined, that would tell you at runtime > > you > > have undefined behavior in your code (if the SingleDiff has bit ever 0x20 > > set). > > Yes, that

Re: GCC turns &~ into | due to undefined bit-shift without warning

2019-03-11 Thread Vincent Lefevre
On 2019-03-11 11:06:37 +, Moritz Strübe wrote: > On 11.03.2019 at 10:14 Jakub Jelinek wrote: > > The fact that negative or >= bit precision shifts are UB is widely known, [...] And even in the case where the compiler maps the shift directly to the asm shift (without optimizations), the behavio

Re: Warning for C Parameter Name Mismatch

2019-03-11 Thread Jonathan Wakely
On Sat, 9 Mar 2019 at 17:27, Segher Boessenkool wrote: > > On Sat, Mar 09, 2019 at 08:30:19AM +, Jonathan Wakely wrote: > > On Sat, 9 Mar 2019, 02:23 Eric Gallager, wrote: > > > How would it handle the case where the parameter name is missing > > > entirely from the prototype? I see a lot of

Re: Warning for C Parameter Name Mismatch

2019-03-11 Thread Jonathan Wakely
On Sat, 9 Mar 2019 at 17:51, Joel Sherrill wrote: > And not checking system headers is reasonable in general. For RTEMS though, > we are implementing those system headers and do follow the names in the > standards for parameter names in the implementation. Using exactly the names from the standa

DECL_SOURCE_LOCATION including return type and template type

2019-03-11 Thread Martin Liška
Hi. For a test-case like: ───┬─ │ File: test.cpp ───┼─ 1 │ template 2 │ T 3 │ abs(T x) { 4 │ if (x < 0) { 5 │ return -x; 6 │ } else { 7 │ return x; 8 │

Re: GCC turns &~ into | due to undefined bit-shift without warning

2019-03-11 Thread David Brown
On 11/03/2019 12:24, Vincent Lefevre wrote: > On 2019-03-11 11:06:37 +, Moritz Strübe wrote: >> On 11.03.2019 at 10:14 Jakub Jelinek wrote: >>> The fact that negative or >= bit precision shifts are UB is widely known, > [...] > > And even in the case where the compiler maps the shift directly

How to add %' into gfc_fatal_error

2019-03-11 Thread Martin Liška
Hi. I would like to add %' into __gcc_gfc__ in order to handle: ./xgcc -B. /tmp/module.ii -Wformat -c /home/marxin/Programming/gcc/gcc/fortran/module.c: In function ‘void dump_module(const char*, int)’: /home/marxin/Programming/gcc/gcc/fortran/module.c:6205:19: warning: unknown conversion type

Re: How to add %' into gfc_fatal_error

2019-03-11 Thread Martin Sebor
On 3/11/19 8:18 AM, Martin Liška wrote: Hi. I would like to add %' into __gcc_gfc__ in order to handle: ./xgcc -B. /tmp/module.ii -Wformat -c /home/marxin/Programming/gcc/gcc/fortran/module.c: In function ‘void dump_module(const char*, int)’: /home/marxin/Programming/gcc/gcc/fortran/module.c:6

Re: How to add %' into gfc_fatal_error

2019-03-11 Thread David Malcolm
On Mon, 2019-03-11 at 15:18 +0100, Martin Liška wrote: > Hi. > > I would like to add %' into __gcc_gfc__ in order to handle: > > ./xgcc -B. /tmp/module.ii -Wformat -c > /home/marxin/Programming/gcc/gcc/fortran/module.c: In function ‘void > dump_module(const char*, int)’: > /home/marxin/Programmin

Re: How to add %' into gfc_fatal_error

2019-03-11 Thread Steve Kargl
On Mon, Mar 11, 2019 at 12:07:55PM -0400, David Malcolm wrote: > On Mon, 2019-03-11 at 15:18 +0100, Martin Liška wrote: > > Hi. > > > > I would like to add %' into __gcc_gfc__ in order to handle: > > > > ./xgcc -B. /tmp/module.ii -Wformat -c > > /home/marxin/Programming/gcc/gcc/fortran/module.c: