Question on GCC 4.6 and -fpermissive

Jonathan Wakely jwakely.gcc@gmail.com
Wed Aug 10 12:28:00 GMT 2011


On 10 August 2011 13:12, Jeffrey Walton wrote:
> On Wed, Aug 10, 2011 at 7:22 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On 10 August 2011 10:32, Jonathan Wakely wrote:
>>>
>>> If you don't want warnings about narrowing then use -Wno-narrow, which
>>> works for me.
>>
>> That should have been -Wno-narrowing, which might be new in 4.7
> OK, thanks.
>
> This might be useful if the language allows it. Rather than issuing 18
> separate warnings on the following - which would require 18 casts:
>
> static const IncTest< __int8 > inc_int8[] =
> {
>       { 0x00, 0x01, true},
>       { 0x01,0x02, true},
>       { 0x02, 0x03, true},
>       { 0x7e, 0x7f, true},
>       { 0x7f, 0x80, false},
>       { 0x80, 0x81, true},
>       { 0x81, 0x82, true},
>       { 0xfe, 0xff, true},
>       { 0xff, 0x00, true},
> };

It doesn't issue 18 warnings, it issues 8, for the narrowing
conversions.  There's no problem converting the constants 0x00 or 0x01
to a char.

> Require us to perform the first cast, and then {accept|imply} the type
> on the remainder since we specified the type on the first element:
>
> static const IncTest< __int8 > inc_int8[] =
> {
>       { (__int8)0x00, (__int8)0x01, true},
>       { 0x01,0x02, true},
>       { 0x02, 0x03, true},
>       { 0x7e, 0x7f, true},
>       { 0x7f, 0x80, false},
>       { 0x80, 0x81, true},
>       { 0x81, 0x82, true},
>       { 0xfe, 0xff, true},
>       { 0xff, 0x00, true},
> };

That would not be conforming. Neither is -Wno-narrowing for that
matter, C++11 says there are 8 errors in that code.



More information about the Gcc-help mailing list