elow case from trunk gcc we get the below
>>>> warning (-Wconversion) i.e
>>>>
>>>> void start(void) {
>>>> char n = 1;
>>>> char n1 = 0x01;
>>>> n &= ~n1;
>>>> }
>>>>
>>>> $xgcc -S w
from trunk gcc we get the below
warning (-Wconversion) i.e
void start(void) {
char n = 1;
char n1 = 0x01;
n &= ~n1;
}
$xgcc -S warn.c -nostdinc -Wconversion
warning: conversion from ‘int’ to ‘char’ may change value
[-Wconversion]
n &= ~n1;
[...]
It looks like a bug to me.
Decl
>>
>>>> When we try to compile the below case from trunk gcc we get the below
>>>> warning (-Wconversion) i.e
>>>>
>>>> void start(void) {
>>>> char n = 1;
>>>> char n1 = 0x01;
>>>> n &= ~n1;
elow case from trunk gcc we get the below
>>>> warning (-Wconversion) i.e
>>>>
>>>> void start(void) {
>>>> char n = 1;
>>>> char n1 = 0x01;
>>>> n &= ~n1;
>>>> }
>>>>
>>>> $xgcc -S warn
= 0x01;
n &= ~n1;
}
$xgcc -S warn.c -nostdinc -Wconversion
warning: conversion from ‘int’ to ‘char’ may change value [-Wconversion]
n &= ~n1;
[...]
It looks like a bug to me.
Declaring n1 const avoids the warning at -O2 but in C but not
at -O0.
Perhaps at some optimization le
On 2018-09-20 11:13:59 -0400, Jason Merrill wrote:
> Indeed, whether this sort of warning is a false positive depends on
> values, which the optimizers can always do better with. We could
> build some logic into the front end, e.g. recognize that a &
> expression will always fit in the smallest of
On 2018-09-20 22:57:00 +0800, Liu Hao wrote:
> 在 2018/9/20 22:08, Vincent Lefevre 写道:
> >> In C++, declaring n1 const avoids the warning regardless of
> >> optimization levels.
> >
> > If the constant propagation is done at -O0, this could explain
> > the behavior.
> >
> > Or do you mean that GCC
> char n = 1;
>> char n1 = 0x01;
>> n &= ~n1;
>> }
>>
>> $xgcc -S warn.c -nostdinc -Wconversion
>> warning: conversion from ‘int’ to ‘char’ may change value [-Wconversion]
>> n &= ~n1;
>>
>> typecast the expression li
在 2018/9/20 22:08, Vincent Lefevre 写道:
>> In C++, declaring n1 const avoids the warning regardless of
>> optimization levels.
>
> If the constant propagation is done at -O0, this could explain
> the behavior.
>
> Or do you mean that GCC remembers the type the data come from,
> i.e. assuming char
> char n = 1;
> > char n1 = 0x01;
> > n &= ~n1;
> > }
> >
> > $xgcc -S warn.c -nostdinc -Wconversion
> > warning: conversion from ‘int’ to ‘char’ may change value [-Wconversion]
> > n &= ~n1;
[...]
> It looks like a bug to me.
>
> Dec
On 09/17/2018 06:00 AM, Umesh Kalappa wrote:
Hi All,
When we try to compile the below case from trunk gcc we get the below
warning (-Wconversion) i.e
void start(void) {
char n = 1;
char n1 = 0x01;
n &= ~n1;
}
$xgcc -S warn.c -nostdinc -Wconversion
warning: conversion from ‘int’ to ‘
dinc -Wconversion
> warning: conversion from ‘int’ to ‘char’ may change value [-Wconversion]
> n &= ~n1;
>
> typecast the expression like "n& = (char)~n1" and warning goes away .
>
> and when we investigated the gcc source and warning coming from
>
Hi All,
When we try to compile the below case from trunk gcc we get the below
warning (-Wconversion) i.e
void start(void) {
char n = 1;
char n1 = 0x01;
n &= ~n1;
}
$xgcc -S warn.c -nostdinc -Wconversion
warning: conversion from ‘int’ to ‘char’ may change value [-Wconversion]
n &am
13 matches
Mail list logo