primitive value overflow

Mr. Anonymous mailnew4ster at gmail.com
Thu May 16 13:35:07 PDT 2013


On Thursday, 16 May 2013 at 20:29:13 UTC, Andrej Mitrovic wrote:
> On Thursday, 16 May 2013 at 20:24:31 UTC, luka8088 wrote:
>> Hello everyone.
>>
>> Today I ran into a interesting issue. I wrote
>>
>>  auto offset = text1.length - text2.length;
>
> Yeah, I don't like these bugs either. In the meantime you can 
> swap auto with 'sizediff_t' or 'ptrdiff_t', and then you can 
> check if it's non-negative.

It's exactly the same as checking if(text1.length > text2.length).
But the idea of checking for integer overflows in debug builds is 
really nice.

P.S. I remember Microsoft had some serious bug because of an 
integer overflow, that allowed a remote machine to create a 
denial of service.


More information about the Digitalmars-d mailing list