Re: Is this OK in C++ and C?
Jerry Stuckle <jstuckle@attglobal.net> writes:
> On 12/31/2012 7:30 PM, Joe Pfeiffer wrote:
>> Jari Fredriksson <jarif@iki.fi> writes:
>>>>
>>> This is a known bug in Debian GNU/Linux. Happy new year ;)
>>
>> Where does the standard require a warning in this case? If no warning
>> is required, the behavior is not a bug.
>>
>>
>
> I don't have a copy of the standard any more, but IIRC it does need a
> warning. It requires a conversion from signed to unsigned, which can
> cause incorrect data (as in this case).
>
> Promotions (i.e. short to int, float to double) will never cause a
> loss of data, and do not require warnings.
>
> But I also admit it's been several years since I looked at the spec
> and my memory isn't what it used to be (at least that's what my wife
> tells me).
Looking into it a bit more, I can't find a place where the C99 standard
requires *any* warnings. In particular:
Annex I
(informative)
Common warnings
1 An implementation may generate warnings in many situations, none of which are
specified as part of this International Standard. The following are a few of the more
common situations.
(a list of warnings follows)
A search doesn't turn up the string "warn" anywhere in the standard
except in this annex.
(granted, I don't have the final standard, just a draft from 2005. But
still...)
Reply to: