Am Fri, 17 May 2013 14:43:08 -0300 schrieb Ary Borenszweig <[email protected]>:
> On 5/16/13 5:24 PM, luka8088 wrote: > > Hello everyone. > > > > Today I ran into a interesting issue. I wrote > > > > auto offset = text1.length - text2.length; > > > > and in case text2 was longer then text1 I got something around 4294967291. > > > > So I opened an issue: > > http://d.puremagic.com/issues/show_bug.cgi?id=10093 > > > > I know that there is a perfectly valid reason for this behavior, and > > that this behavior is not undefined, but it is unexpected, especially > > because unsigned is never mentioned in the code. One solution that comes > > to mind is changing length to signed, but that makes no sense because > > length is never negative. > > It makes sense if you don't want to have these subtle bugs in your > programming language -.- Just saying: the subtraction of two integers creates a resulting range that doesn't fit in ANY integer of same size. If you want to be safe disallow subtraction -.- -- Marco
