Bug in ^^

Vladimir Panteleev thecybershadow.lists at gmail.com
Tue Sep 17 19:36:14 UTC 2019

On Tuesday, 17 September 2019 at 19:22:44 UTC, Timon Gehr wrote:
> It's not the same. C compilers warn about overflows that are 
> UB. They don't complain about overflows that have defined 
> behavior:

I'm not so sure that's the actual distinction.

The error messages do not mention undefined behavior.

The GCC source code for this does not mention undefined behavior:


The clang source code does not mention anything about undefined 


It seems to me that the more likely explanation is that making 
the operands unsigned is a method of squelching the warning.

> In D, all overflows in operations on basic integer types have 
> defined behavior, not just those operating on unsigned integers.

Regardless of what other languages do, or the pedantic details 
involved, it seems to me that warning on detectable overflows 
would simply be more useful for D users (provided there is a way 
to squelch the warning). Therefore, D should do it.

More information about the Digitalmars-d mailing list