signed/unsigned integer conversion for right shift seems

Peter T. Breuer
Tue Feb 6 17:19:00 GMT 2018

"Also sprach Jonathan Wakely:"
> >> No, because the operands of bitshift operators aren't balanced to a common type.
> >
> > Where does it say that? Your word isn't quite enough for me :-(.
> You've already been told that 6.5.7 says "The integer promotions are
> performed on each of the operands. " and says nothing about
> conversions.

If that were a valid mode of reasoning it would apply to the operands of
arithmetic operators to which conversion IS applied.  (Which are they?)

Ergo, it is not. No flowers in this instance :-(.

Is there somewhere where it DOES say that conversions should be
applied to SOMETHING?

> > It doesn't require the rules to be applied, it only talks about WHEN
> > they are applied. It leaves it open as to to which operators that
> > the conversion rules are to be appled to.
> The specification of each operator tells you if it's applied. 6.5.7
> doesn't say they are, so they aren't.

I don't have a "specification of each operator" to look at ... probably
it doesn't junp out from google for me as easily as other stuff does.

I wonder if I could I ask you to quote the ">>" specification for my
lazy self?

Perhaps also let me know what else conversion does and does not apply

BTW, NOT saying something is applied in a specification should not mean
that it is forbidden, as a general principle of specification languages.
Is there somewhere in the C specification general blurb that says "no
say, no do"?

I admit my reason for supposing PROMOTION is not done was because I
could find no rule that says to.  But in that matter I am willing to
believe it can or cannot be done in some (other) compiler
implementation, whatever it should amount to in that case. Not doing
is what happens with gcc.

> > No, I conclude whatever is logically required, and point out false
> > aka mistaken logic where it is attempted. I don't mind what answer
> > you or I get, so long as it is reasoned correctly, or at least
> > convincingly.
> >
> > I haven't yet seen a constructive argument towards what I see as
> > the probable out - that >> is just one of the 3 or 4 exceptions.
> Then you're not paying attention.

You seem loathe to quote where it says that conversion MAY NOT or MUST
NOT be applied to the arguments of >>. Unfortunately I can't work off
word of mouth.

Which of may or must not is it, since you know!

> >   If the operand that has unsigned integer type has rank greater than
> >   or equal to the rank of the type of the other operand, the operand
> >   with signed integer type is converted to the type of the operand with
> >   unsigned integer type.
> >
> > So / and likely % (yes?) are likely other exceptions.

> > Is there somewhere in the standard where it SAYS ...

Regards and thanks


More information about the Gcc-help mailing list