Signed integer overflow undefined behavior or not?

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 13 00:30:19 PST 2015


On Friday, 13 November 2015 at 06:46:37 UTC, Ali Çehreli wrote:
> Since it's UB in C and C++, I've heard that both clang and gcc 
> do remove code branches if they can prove that there will be 
> signed overflow. I don't know how or whether that optimization 
> is turned off for D.

The question you want to ask is probably if modular arithmetics 
is legal D code for all integers, signed and unsigned. Can the 
programmer assume that wrapping is legal D code?

If so, then D does not have any kind of integer overflow at all, 
by definition.



More information about the Digitalmars-d mailing list