Undefined behaviors & Clang 3.3

eles eles at eles.com
Fri Jun 21 17:14:18 PDT 2013


On Friday, 21 June 2013 at 15:51:55 UTC, qznc wrote:
> On Friday, 21 June 2013 at 13:48:19 UTC, eles wrote:
>> On Friday, 21 June 2013 at 10:42:32 UTC, bearophile wrote:
>
> The D definition mirrors what modern PC architectures do and 
> hence can be compiled efficiently there. C avoids coupling with 
> any architecture hence "undefined".

First, it is not just about UNDEFINED behaviour, but also about 
DESIRED behaviur. C's arrays seen as pointers were efficient (and 
mirroring the architecture who kne nothing about arrays, just 
about addresses, that is pointers), still D abandoned them for a 
good reason.

Efficiency vs better is a sensible trade-off.

Secondly, is just enabling that overflow behavior if chasing a 
bug, explicitely, with a compiler flag. Use it only if you care.

Although the best solution, in my eyes, is to have both wrapping 
and overfloing signed and unsigned integer types. Chose what you 
want.

> What architectures do not wrap around?


They wrap, but they carry.

BTW, floats do not wrap, why integers should behave otherwise?


More information about the Digitalmars-d mailing list