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:
https://github.com/gcc-mirror/gcc/blob/5fe20025f581fb0c215611434d76696161d4cbd3/gcc/c-family/c-warn.c#L70
The clang source code does not mention anything about undefined
behavior:
https://github.com/CyberShadow/llvm-project/blob/6e4932ebe9448b9bab922b225a8012669972ff0c/clang/lib/AST/ExprConstant.cpp#L2310
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