Re: primitive value overflow

2013-05-29 Thread luka8088
On 24.5.2013. 1:58, bearophile wrote: Peter Alexander: What about code that relies on overflow? It's well-defined behaviour, so it should be expected that people rely on it (I certainly do sometimes) Do you rely on signed or unsigned overflow? My opinions on this topic have changed few times

Re: primitive value overflow

2013-05-26 Thread Marco Leise
Good that we talked about it. -- Marco

Re: primitive value overflow

2013-05-25 Thread Timothee Cour
A) Requiring a construct such as Checked!int is too complicated for the user in general as it requires a lot of code change from the user. It may be useful in certain cases but overflow bugs will crop up in unexpected places. B) To help finding such bugs, introduce a special version identifier for

Re: primitive value overflow

2013-05-23 Thread Marco Leise
Am Fri, 24 May 2013 01:35:42 +0200 schrieb "Peter Alexander" : > What about code that relies on overflow? It's well-defined > behaviour, so it should be expected that people rely on it (I > certainly do sometimes) See my post about Delphi's approach. It could be disabled in D using pragma(), UD

Re: primitive value overflow

2013-05-23 Thread bearophile
Peter Alexander: What about code that relies on overflow? It's well-defined behaviour, so it should be expected that people rely on it (I certainly do sometimes) Do you rely on signed or unsigned overflow? My opinions on this topic have changed few times. A modern system language should off

Re: primitive value overflow

2013-05-23 Thread Peter Alexander
On Saturday, 18 May 2013 at 20:29:57 UTC, Minas Mina wrote: I agree that checks for overflow should exist in debug builds (and not exist in release builds). What about code that relies on overflow? It's well-defined behaviour, so it should be expected that people rely on it (I certainly do so

Re: primitive value overflow

2013-05-23 Thread Marco Leise
Am Thu, 23 May 2013 19:55:36 +0200 schrieb luka8088 : > I understand perfectly the issue that you are pointing out. But that is > not the real issue here. I know how computer arithmetic works, the > understanding is not the issue here. The real issue is that at the time > of writing unsigned wa

Re: primitive value overflow

2013-05-23 Thread luka8088
On 17.5.2013. 0:23, Marco Leise wrote: Am Thu, 16 May 2013 22:39:16 +0200 schrieb luka8088: On 16.5.2013. 22:29, 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.

Re: primitive value overflow

2013-05-18 Thread Minas Mina
I agree that checks for overflow should exist in debug builds (and not exist in release builds).

Re: primitive value overflow

2013-05-18 Thread Marco Leise
Am Fri, 17 May 2013 14:43:08 -0300 schrieb Ary Borenszweig : > 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

Re: primitive value overflow

2013-05-17 Thread Ary Borenszweig
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

Re: primitive value overflow

2013-05-17 Thread Regan Heath
On Thu, 16 May 2013 23:23:20 +0100, Marco Leise wrote: Am Thu, 16 May 2013 22:39:16 +0200 schrieb luka8088 : On 16.5.2013. 22:29, 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 >> >> aut

Re: primitive value overflow

2013-05-16 Thread Marco Leise
Am Thu, 16 May 2013 22:39:16 +0200 schrieb luka8088 : > On 16.5.2013. 22:29, 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; > > >

Re: primitive value overflow

2013-05-16 Thread 1100110
On 05/16/2013 04:17 PM, Mr. Anonymous wrote: > On Thursday, 16 May 2013 at 21:04:38 UTC, Jonathan M Davis wrote: >> On Thursday, May 16, 2013 22:42:23 luka8088 wrote: >>> I agree that it is exactly the same as checking if (text1.length > >>> text2.length). And I don't think that this is an issues i

Re: primitive value overflow

2013-05-16 Thread Mr. Anonymous
On Thursday, 16 May 2013 at 21:04:38 UTC, Jonathan M Davis wrote: On Thursday, May 16, 2013 22:42:23 luka8088 wrote: I agree that it is exactly the same as checking if (text1.length > text2.length). And I don't think that this is an issues if you are aware of the fact that you are working with

Re: primitive value overflow

2013-05-16 Thread Andrej Mitrovic
On 5/16/13, Jonathan M Davis wrote: > The hardware doesn't support it, and it would definitely > be slow if it were added. We could add it in -debug mode perhaps. Ideally this sort of thing would be its own switch, but yes that goes towards switch proliferation, I know the story.

Re: primitive value overflow

2013-05-16 Thread Jonathan M Davis
On Thursday, May 16, 2013 22:42:23 luka8088 wrote: > I agree that it is exactly the same as checking if (text1.length > > text2.length). And I don't think that this is an issues if you are aware > of the fact that you are working with unsigned values. But in the code > that I wrote there was no men

Re: primitive value overflow

2013-05-16 Thread luka8088
On 16.5.2013. 22:35, Mr. Anonymous wrote: 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 th

Re: primitive value overflow

2013-05-16 Thread luka8088
On 16.5.2013. 22:29, 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 'sizedif

Re: primitive value overflow

2013-05-16 Thread Mr. Anonymous
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

Re: primitive value overflow

2013-05-16 Thread Andrej Mitrovic
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 che

primitive value overflow

2013-05-16 Thread luka8088
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 vali