On 06/06/2012 07:35 AM, Hill Pang wrote:
> On Wednesday, June 6, 2012 5:42:13 PM UTC+8, Hill Pang wrote:
>> I was expecting a warning for this assignment, but can't get from GCC, why? isn't it an overflow?
>>
>> char c = 0xff;
>
> Thanks, every one!
>
> Yes, with additional options, the warning shows, but for me I think it is straight to check if a const is in the represent-able range of a variable in an assignment, I think the warning should be popped up by default rather by an extra option. I am wondering if there is some special rulers behind this, is there any such ruler listed in the C standard or some place anywhere?
The C standard mandates certain diagnostics. gcc does not provide all of
the mandated diagnostics for any version of the C standard (and is
therefore not a conforming implementation of C) without either the -ansi
or the -std= options, plus -pedantic. There's LOTS of additional useful
warnings not mandated by the C standard, and you need to explicitly
request them; -Wall gets most of the most useful ones. I like to add
-Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes
|