Re: Is this OK in C++ and C?
On Wednesday 02 of January 2013 05:25:19 Tixy wrote:
> On Tue, 2013-01-01 at 11:41 -0700, Joe Pfeiffer wrote:
> > 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.
>
> But it probably has quite a few occurrences of 'diagnostic', the C++
> standard does; and it states that a 'diagnostic message' shall be issued
> if a program breaks the rules of the language except where the standard
> explicitly states no diagnostic is required.
>
> With regard to the original question of assigning a negative value to an
> unsigned integer, this seems to be allowed and defined behaviour. The
> section on integral conversions has:
>
> If the destination type is unsigned, the resulting value is the
> least unsigned integer congruent to the source integer (modulo 2
> n where n is the number of bits used to represent the unsigned
> type). [Note: In a two’s complement representation, this
> conversion is conceptual and there is no change in the bit
> pattern (if there is no truncation). ]
>
Thank you all for your help in understanding my problem.
Best regards,
Zbigniew
Reply to: