Re: This seems like what could be a common cause of bugs

2011-08-15 Thread bearophile
Marco Leise: That's why Pascal uses another set of operators for integer divisions, namely 'div' and 'mod', so you can never get into that situation. The above code would have worked and in case step was an integer, the compiler would have complained about not using 'div'. I doubt that

Re: This seems like what could be a common cause of bugs

2011-08-14 Thread Marco Leise
Am 09.07.2011, 00:45 Uhr, schrieb Andrej Mitrovic andrej.mitrov...@gmail.com: This is just an observation, not a question or anything. void main() { enum width = 100; double step = 1 / width; writeln(step); // 0 } I've just had this bug in my code. I forgot to make either

Re: This seems like what could be a common cause of bugs

2011-07-22 Thread Don
Andrej Mitrovic wrote: This is just an observation, not a question or anything. void main() { enum width = 100; double step = 1 / width; writeln(step); // 0 } I've just had this bug in my code. I forgot to make either width or 1 a floating-point type. IOW, I didn't do this: void

Re: This seems like what could be a common cause of bugs

2011-07-13 Thread Kagamin
Steven Schveighoffer Wrote: On Tue, 12 Jul 2011 11:07:57 -0400, Kagamin s...@here.lot wrote: Steven Schveighoffer Wrote: Yes, but this is getting into territory where the false positive rate might get high. I bet it will be difficult to find a real-world example of this false

Re: This seems like what could be a common cause of bugs

2011-07-12 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 16:46:07 -0400, Nick Sabalausky a@a.a wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message Hm... I didn't know about that switch, I thought warnings were enabled with -w and that made them errors. I suppose you could stick this in there. -wi: Enable

Re: This seems like what could be a common cause of bugs

2011-07-12 Thread Kagamin
Steven Schveighoffer Wrote: Yes, but this is getting into territory where the false positive rate might get high. I bet it will be difficult to find a real-world example of this false positive.

Re: This seems like what could be a common cause of bugs

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 11:07:57 -0400, Kagamin s...@here.lot wrote: Steven Schveighoffer Wrote: Yes, but this is getting into territory where the false positive rate might get high. I bet it will be difficult to find a real-world example of this false positive. It depends on how the

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Steven Schveighoffer
On Sat, 09 Jul 2011 13:28:25 -0400, Nick Sabalausky a@a.a wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vybq4xkkeav7ka@localhost.localdomain... On Fri, 08 Jul 2011 18:45:58 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: This is just an observation, not a

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Steven Schveighoffer
On Sat, 09 Jul 2011 07:38:39 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vybo0hv1eav7ka@localhost.localdomain... 1. is a horrible legacy thing, and should be removed. -Steve This I hate, but I'd hate to lose 1.f and

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Daniel Murphy
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vygk71eweav7ka@localhost.localdomain... What's wrong with 1.0f and 1.0L ? -Steve It's one character longer! Mostly it's just a habit I've gotten into. I'd likely be able to get used to writing the zero fairly easily.

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 10:45:16 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vygk71eweav7ka@localhost.localdomain... What's wrong with 1.0f and 1.0L ? -Steve It's one character longer! 1f is one character shorter :P

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Daniel Murphy
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vygm6auqeav7ka@localhost.localdomain... 1f is one character shorter :P (BTW, not sure the grammar currently supports this one, even though it compiles. I think: Integer FloatSuffix should be added. I admit, there is no

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 11:22:40 -0400, Daniel Murphy yebbl...@nospamgmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vygm6auqeav7ka@localhost.localdomain... 1f is one character shorter :P (BTW, not sure the grammar currently supports this one, even though it

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Jonathan M Davis
On Monday 11 July 2011 08:17:50 Steven Schveighoffer wrote: On Sat, 09 Jul 2011 13:28:25 -0400, Nick Sabalausky a@a.a wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vybq4xkkeav7ka@localhost.localdomain... On Fri, 08 Jul 2011 18:45:58 -0400, Andrej Mitrovic

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 11:45:47 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Monday 11 July 2011 08:17:50 Steven Schveighoffer wrote: Hm... I didn't know about that switch, I thought warnings were enabled with -w and that made them errors. I suppose you could stick this in there.

Re: This seems like what could be a common cause of bugs

2011-07-11 Thread Nick Sabalausky
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vyge30ogeav7ka@localhost.localdomain... On Sat, 09 Jul 2011 13:28:25 -0400, Nick Sabalausky a@a.a wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vybq4xkkeav7ka@localhost.localdomain... On Fri, 08 Jul

Re: This seems like what could be a common cause of bugs

2011-07-09 Thread Jacob Carlborg
On 2011-07-09 01:03, Steven Schveighoffer wrote: On Fri, 08 Jul 2011 18:47:55 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 7/9/11, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: double step = 1 / width; // or .1 Woops that should have been `1.`. See, another bug right

Re: This seems like what could be a common cause of bugs

2011-07-09 Thread Daniel Murphy
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vybo0hv1eav7ka@localhost.localdomain... 1. is a horrible legacy thing, and should be removed. -Steve This I hate, but I'd hate to lose 1.f and 1.L

Re: This seems like what could be a common cause of bugs

2011-07-09 Thread Nick Sabalausky
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vybq4xkkeav7ka@localhost.localdomain... On Fri, 08 Jul 2011 18:45:58 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: This is just an observation, not a question or anything. void main() { enum width = 100;

This seems like what could be a common cause of bugs

2011-07-08 Thread Andrej Mitrovic
This is just an observation, not a question or anything. void main() { enum width = 100; double step = 1 / width; writeln(step); // 0 } I've just had this bug in my code. I forgot to make either width or 1 a floating-point type. IOW, I didn't do this: void main() { enum width

Re: This seems like what could be a common cause of bugs

2011-07-08 Thread Andrej Mitrovic
On 7/9/11, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: double step = 1 / width; // or .1 Woops that should have been `1.`. See, another bug right there!

Re: This seems like what could be a common cause of bugs

2011-07-08 Thread Steven Schveighoffer
On Fri, 08 Jul 2011 18:47:55 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 7/9/11, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: double step = 1 / width; // or .1 Woops that should have been `1.`. See, another bug right there! 1.0 1. is a horrible legacy thing,

Re: This seems like what could be a common cause of bugs

2011-07-08 Thread Andrej Mitrovic
On 7/9/11, Steven Schveighoffer schvei...@yahoo.com wrote: On Fri, 08 Jul 2011 18:47:55 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 7/9/11, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: double step = 1 / width; // or .1 Woops that should have been `1.`. See,

Re: This seems like what could be a common cause of bugs

2011-07-08 Thread bearophile
Andrej Mitrovic: enum width = 100; double step = 1 / width; ... This seems like a very easy mistake to make. Right, it was present even in Python 2.x: http://ideone.com/BEZqq The bug you have found is common enough to deserve a so fundamental change in Python, they have improved it

Re: This seems like what could be a common cause of bugs

2011-07-08 Thread Steven Schveighoffer
On Fri, 08 Jul 2011 18:45:58 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: This is just an observation, not a question or anything. void main() { enum width = 100; double step = 1 / width; writeln(step); // 0 } I've just had this bug in my code. I forgot to make