This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: signed/unsigned integer conversion for right shift seems


On 6 February 2018 at 19:27, Peter T. Breuer <ptb@inv.it.uc3m.es> wrote:
> "Also sprach Jonathan Wakely:"
>> >> See the C standard.
>> >
>> > Where specifically?  I am now looking at the draft standard for
>> > ISO-whatever at
>> >
>> >   http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
>>
>> The specification of each operator of course!
>
> I am and have been looking straight at them, and I see nothing that
> says that conversions should not be applied to their operators.
>
>
>> You've been pointed to them multiple times now, 6.5.5, and 6.5.6, and
>> 6.5.7, and so on.
>
> They contain nothing (6.5.7 is the ony one on the bitwise shift
> operators; 6.5.5 is additive operators, 6.5.6 is multiplicative). We
> have been quoting what 6.5.7 says here.
>
>> Are you trolling or just stubborn and unable to accept the help you asked for?
>
> I would be grateful if you desisted from ad hominen attacks.

Stop acting like an idiot then.

> WHAT, specifically, do you see in 6.5.7 that allows the conversion
> specified by the general rule of conversions
>
>  If one operand has an unsigned type T whose conversion rank is at least
>  as high as that of the other operand's type, then the other operand is
>  converted to type T.
>
> NOT to be applied?

Because it doesn't say they are applied. As I pointed out in
https://gcc.gnu.org/ml/gcc-help/2018-02/msg00031.html the other
operators *do* say the conversions are applied.


> You've been hot on claiming you have done the pointing, but light on
> doing it!  It should not be hard.
>
>> Maybe this will help:
>> http://en.cppreference.com/w/c/language/conversion#Usual_arithmetic_conversions
>
>    The arguments of the following arithmetic operators undergo implicit
>    conversions for the purpose of obtaining the common real type, which
>    is the type in which the calculation is performed:
>    binary arithmetic *, /, %, +, -
>    relational operators <, >, <=, >=, ==, !=
>    binary bitwise arithmetic &, ^, |,
>    the conditional operator ?:
>
> That's all. No ">>" operator there, so no maybe. Your claim is false
> there.

Exactly, the shift operators are not listed there, because the
conversions are not done for the shift operators.

>> And specifically:
>
>> http://en.cppreference.com/w/c/language/operator_arithmetic#Shift_operators
>
> That's a different place ... it seems to say what we have already
> quoted in the standard.
>
>   First, integer promotions are performed, individually, on each operand
>   (Note: this is unlike other binary arithmetic operators, which all
>   perform usual arithmetic conversions). The type of the result is the
>   type of lhs after promotion.
>
> No integer promotions can be performed, since the args are already ints.

Read the parenthesis! It explicitly says that for these operators,
unlike most others, arithmetic conversions are not performed!


> There is no "Second".
>
> If they meant to say
>
>   "Second: NO sign conversions MAY be performed, so what you get after
>   (possibly vacuuous) int promotion you are stuck with, "
>
> then they forgot to say it.

You are an idiot.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]