Re: Integral conversions in C/C++

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

 



John Love-Jensen wrote:

As I understand the discussion, the concern was that the negation of a
uint32_t was undesirably an uint32_t.

That, but in actuality an uint32_t typed result of a 32 bit unsigned
int multiplication although the ISA of the target provides a 64<-32x32
insn that is not emitted due to the frontend hiding this information
from the backend.

uint16_t * uint16_t ==> int32_t

Yep, multiplying two uint16_t results in a int32_t, not a uint32_t.
Surprise!

No surprise here.  Before multiplication, integral promotion makes
int32_ts from the uint16_ts on this particular machine.  Try that on
16 and 64 bit machines and the result types of (s * s) will be
uint16_t and int64_t, respectively.  Since in this example both
uint16_t operands are promoted to the same type no further ``usual
arithmetic conversions'' are applied.  Integral promotion comes
with the catch of promoting only up to int or unsigned int
whatever that on the target may be.

This forum cannot change the standard.

It can discuss details of its implementation in GCC.

If anyone wants to change C, or C++, the result is something that
> may be similar to C or C++, but is not C or C++.

The GNU people have introduced their fair share of mostly private
extensions particularily to C themselves so this ML may actually be
more appropriate than it may initially seem.

But on the bright side, D Programming Language implements 95%+ of
> what I would have liked in my own homebrew language, and
has a GCC implementation (gdc).

Well, I make hardware and write code for a living and the industry
being what it is very much sets the rules within which that happens.

PS:  I once had a chance to talk to Bjarne Stroustrup, with my litany of
complaints with C++.  He stopped me short, and replied (paraphrased) "If you
do not like C++, you are free to create your own language. I did."

Quite.  If both of you were given the exact same preconditions,
your language may have been evolved into something similar.  Notice
that C++ has been industry backed from the start while the rest of
the language bunch apparently only has educational character.  The
point being here that a language itself is useless unless an
implementation for a particular hardware exists.  Unless your
application is on a PeeCee, you're out of luck with most of these.


Cheers,
Christian


[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