Re: signed/unsigned integer conversion for right shift seems against

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 6, 2018 at 5:17 PM, Peter T. Breuer <ptb@xxxxxxxxxxxxxx> wrote:
> "Also sprach Tadeus Prastowo:"
>> > ...................................... The type of E1 is UNSIGNED INT
>> > by the type promotion/conversion rules I quoted.
>>
>> To quote the same document's Section 6.5.7 Paragraph 3: The integer
>> promotions are performed on each of the operands. The type of the
>> result is that of the promoted left operand.  End quote.

[...]

> So I don't see the final sentence
> as relevant.

It is relevant.  See below.

> (I'm quoting something at CMU, rather than wherever you are quoting
> from,
> https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules
> simply because I have to quote something and that's what google is
> showing me)

Which "standard" are you going to follow?  CMU's one, which you
quoted, or the one followed by GCC, which is the ISO-IEC 9899:1999,
which I quoted and whose link I gave you already in my first response
to you?

> We should be looking at the rules for conversions, not promotions.
>
>> So, E1 has type signed int, hasn't it?

[...]

> I agree as far
> as that goes (see end of para)

[...]

> I contend we are then supposed additionally
> to CONVERT, not promote, by the "usual arithmetic conversion" rules.

So, by the second sentence of the ISO-IEC paragraph at the top of this
e-mail, the second sentence that you said irrelevant, you know that E1
>> E2 has the type of E1 after integer promotion.  Now you contend
that there must be a conversion.  One possibility is by the assignment
operator.  But, as you can see, the type of the expression E1 >> E2
already matches the type of the left operand of the assignment
operator.  So, no conversion takes place.

If you still argue that a conversion must take place, now it is your
turn to quote the ISO-IEC 9899:1999 document to support your argument.

> Regards
>
> PTB

--
Best regards,
Tadeus



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux