On 2013-04-21, Paul Sokolovsky <[email protected]> wrote:
> It's all nice and good. But there's difference between "undefined",
> "any value" and "weird".
No, there isn't. "Undefined" means _exactly_ that: you might get any
value -- no matter how "wierd" you think it.
> Because "too many bits" shifts may be undefined in C standard, but
> shifts by arbitrary number of bits are very well defined in
> arithmetic - and by very definition of (unsigned) shift, any value
> shifted by more bits than available in its representation is 0.
That's not what the C standard says.
> That's logical, that's what users know, that's what they expect from
> compiler,
They're wrong to expect that. If the standard says the result is
undefined, then expecting anything in particular is wrong.
> So, msp430-gcc just masks out higher bits of shift count, and in this
> case leaves original value intact. Which turns term ((1 << BITS) -
> 1), which is common to do BITS-modular arithmetic, and would be
> expected to just optimize out in case of a full type, into an
> expression killer with infinite loops, etc. ensuing.
If you write incorrect code, you oughtn't be surprised when it behaves
incorrectly.
--
Grant Edwards grant.b.edwards Yow! Will this never-ending
at series of PLEASURABLE
gmail.com EVENTS never cease?
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users