digitalmars.D.bugs - dmd 125 - is this a bug?
- clayasaurus (22/22) May 23 2005 the following code
- Lionello Lunesu (2/2) May 23 2005 Maybe it asserts that subsequent values be different :-)
- clayasaurus (2/6) May 23 2005 bah... rand_seed(getUTCtime(), 0) then : )
- clayasaurus (4/32) May 23 2005 Ok, I've found out that if I add a return 0 at the end it doesn't assert...
- Ben Hinkle (4/7) May 23 2005 That's the compiler being nice and asserting that you should return
- Lionello Lunesu (7/17) May 24 2005 If the _compiler_ would have been nice, he'd have mentioned it while
- Derek Parnell (8/12) May 24 2005 Not really. It gives you control over whether or not to issue an error i...
- clayasaurus (4/17) May 24 2005 The only problem I have with the -w switch is that it stops giving
- Derek Parnell (7/25) May 24 2005 Yes, I agree that this is a big nuisance. I think that Walter regards
- Stewart Gordon (10/20) May 24 2005 Why doesn't DMD, in its default configuration, report _all_ _errors_?
- Derek Parnell (8/28) May 24 2005 I don't know. I was just trying to give Walter the benefit of the doubt....
- Walter (3/8) May 25 2005 There was a loooong thread about that not so long ago...
- Walter (4/6) May 23 2005 The code "falls of the end" and doesn't have a return statement. Hence, ...
- Unknown W. Brackets (3/7) May 23 2005 IMHO, it'd be release nice if the assert could have a tiny bit more
- clayasaurus (5/17) May 23 2005 It would be nice if assert could take a char[] so you can give a nice
- Walter (6/10) May 23 2005 It's a common request. Assertion failures are for the developer, not the...
- Unknown W. Brackets (14/18) May 24 2005 That's true; in many cases, the file and line will be all that's needed....
- Lionello Lunesu (5/14) May 24 2005 That's odd. You know this is illegal at compile time. So make it an erro...
- Derek Parnell (10/20) May 24 2005 Because there are some circumstances in which it is not illegal, and oth...
- Walter (14/30) May 25 2005 error.
- Stewart Gordon (11/24) May 26 2005 Is it me, or are you talking at cross purposes with the rest of us? You...
the following code import std.random, std.stdio; int main() { rand_seed(0,0); for (int i = 0; i < 10; i++) writefln(rand()); } outputs... 3333243700 473838585 2856274370 1850229479 3777857304 3173865323 2116055926 3788284210 3873632863 598163586 Error: AssertError Failure random(10) ?? I don't get it.
May 23 2005
Maybe it asserts that subsequent values be different :-) ....Just kidding...
May 23 2005
Lionello Lunesu wrote:Maybe it asserts that subsequent values be different :-) ....Just kidding...bah... rand_seed(getUTCtime(), 0) then : )
May 23 2005
clayasaurus wrote:the following code import std.random, std.stdio; int main() { rand_seed(0,0); for (int i = 0; i < 10; i++) writefln(rand()); } outputs... 3333243700 473838585 2856274370 1850229479 3777857304 3173865323 2116055926 3788284210 3873632863 598163586 Error: AssertError Failure random(10) ?? I don't get it.Ok, I've found out that if I add a return 0 at the end it doesn't assert. Here is the simplest test case... int main() {}
May 23 2005
Ok, I've found out that if I add a return 0 at the end it doesn't assert. Here is the simplest test case... int main() {}That's the compiler being nice and asserting that you should return something when you exit a function that is declared to return something. This has come up before so I'd poke around in the archives for more background.
May 23 2005
If the _compiler_ would have been nice, he'd have mentioned it while compiling :-) This is just the compiler being nasty and inserting an assert(0) in your code. L. "Ben Hinkle" <bhinkle mathworks.com> wrote in message news:d6t3pt$1l9d$1 digitaldaemon.com...Ok, I've found out that if I add a return 0 at the end it doesn't assert. Here is the simplest test case... int main() {}That's the compiler being nice and asserting that you should return something when you exit a function that is declared to return something. This has come up before so I'd poke around in the archives for more background.
May 24 2005
On Tue, 24 May 2005 10:33:05 +0300, Lionello Lunesu wrote:If the _compiler_ would have been nice, he'd have mentioned it while compiling :-) This is just the compiler being nasty and inserting an assert(0) in your code.Not really. It gives you control over whether or not to issue an error in this situation. If you want to be told about these situations, compile using the "-w" switch. -- Derek Parnell Melbourne, Australia 24/05/2005 7:56:09 PM
May 24 2005
Derek Parnell wrote:On Tue, 24 May 2005 10:33:05 +0300, Lionello Lunesu wrote:The only problem I have with the -w switch is that it stops giving warnings after the first few, so you are forced to fix the warnings if you want more.If the _compiler_ would have been nice, he'd have mentioned it while compiling :-) This is just the compiler being nasty and inserting an assert(0) in your code.Not really. It gives you control over whether or not to issue an error in this situation. If you want to be told about these situations, compile using the "-w" switch.
May 24 2005
On Tue, 24 May 2005 12:54:51 +0000, clayasaurus wrote:Derek Parnell wrote:Yes, I agree that this is a big nuisance. I think that Walter regards "warning" as just another type of "error" ;-) -- Derek Parnell Melbourne, Australia 25/05/2005 7:22:41 AMOn Tue, 24 May 2005 10:33:05 +0300, Lionello Lunesu wrote:The only problem I have with the -w switch is that it stops giving warnings after the first few, so you are forced to fix the warnings if you want more.If the _compiler_ would have been nice, he'd have mentioned it while compiling :-) This is just the compiler being nasty and inserting an assert(0) in your code.Not really. It gives you control over whether or not to issue an error in this situation. If you want to be told about these situations, compile using the "-w" switch.
May 24 2005
Derek Parnell wrote:On Tue, 24 May 2005 10:33:05 +0300, Lionello Lunesu wrote:Why doesn't DMD, in its default configuration, report _all_ _errors_? How can int qwert() {} possibly be what the programmer meant? http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/3817 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.If the _compiler_ would have been nice, he'd have mentioned it while compiling :-) This is just the compiler being nasty and inserting an assert(0) in your code.Not really. It gives you control over whether or not to issue an error in this situation. If you want to be told about these situations, compile using the "-w" switch.
May 24 2005
On Tue, 24 May 2005 18:00:55 +0100, Stewart Gordon wrote:Derek Parnell wrote:I don't know. I was just trying to give Walter the benefit of the doubt. I too think that *obvious* mistakes like that need to be considered in the same light as " if ( whatever ) ;" -- Derek Parnell Melbourne, Australia 25/05/2005 7:24:23 AMOn Tue, 24 May 2005 10:33:05 +0300, Lionello Lunesu wrote:Why doesn't DMD, in its default configuration, report _all_ _errors_? How can int qwert() {} possibly be what the programmer meant? http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/3817If the _compiler_ would have been nice, he'd have mentioned it while compiling :-) This is just the compiler being nasty and inserting an assert(0) in your code.Not really. It gives you control over whether or not to issue an error in this situation. If you want to be told about these situations, compile using the "-w" switch.
May 24 2005
"Stewart Gordon" <smjg_1998 yahoo.com> wrote in message news:d6vmk7$1r82$1 digitaldaemon.com...Why doesn't DMD, in its default configuration, report _all_ _errors_? How can int qwert() {} possibly be what the programmer meant? http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/3817There was a loooong thread about that not so long ago...
May 25 2005
"clayasaurus" <clayasaurus gmail.com> wrote in message news:d6t0lq$1i1d$1 digitaldaemon.com...Error: AssertError Failure random(10) ?? I don't get it.The code "falls of the end" and doesn't have a return statement. Hence, the compiler inserts an assert. Try compiling with -w.
May 23 2005
IMHO, it'd be release nice if the assert could have a tiny bit more information attached to it... e.g. "function exit without return value." -[Unknown]Error: AssertError Failure random(10)The code "falls of the end" and doesn't have a return statement. Hence, the compiler inserts an assert. Try compiling with -w.
May 23 2005
Unknown W. Brackets wrote:IMHO, it'd be release nice if the assert could have a tiny bit more information attached to it... e.g. "function exit without return value." -[Unknown]It would be nice if assert could take a char[] so you can give a nice message like... assert(false, "assert description..."); and have a message like Error: AssertError Failure random(10) : assert description...Error: AssertError Failure random(10)The code "falls of the end" and doesn't have a return statement. Hence, the compiler inserts an assert. Try compiling with -w.
May 23 2005
"clayasaurus" <clayasaurus gmail.com> wrote in message news:d6tohj$2abi$1 digitaldaemon.com...It would be nice if assert could take a char[] so you can give a nice message like... assert(false, "assert description..."); and have a message like Error: AssertError Failure random(10) : assert description...It's a common request. Assertion failures are for the developer, not the end user. They give the file/line of the assert that tripped. Any comments about what went wrong should be in the comments next to the assert. I am not seeing why it should be put into the executable, it just seems redundant.
May 23 2005
That's true; in many cases, the file and line will be all that's needed. However, there are times when that is not the case: 1. When the compiler inserts an assertion automatically, it can be confusing without a short description. 2. In an open source environment, where a third-party developer may have patched or greatly modified his source, making it hard to match up line numbers (this is worse if you leave asserts/dbc on for a release or beta, which isn't completely uncommon.) In any case, if I had the option to include a comment for asserts, I still wouldn't use it all of the time. But, there are cases where I would want to be able to put some text there. I guess a solution would be an exception thrown only in debug mode, which takes __FILE__ and __LINE__... -[Unknown]It's a common request. Assertion failures are for the developer, not the end user. They give the file/line of the assert that tripped. Any comments about what went wrong should be in the comments next to the assert. I am not seeing why it should be put into the executable, it just seems redundant.
May 24 2005
That's odd. You know this is illegal at compile time. So make it an error. No? L. "Walter" <newshound digitalmars.com> wrote in message news:d6t52f$1ml0$1 digitaldaemon.com..."clayasaurus" <clayasaurus gmail.com> wrote in message news:d6t0lq$1i1d$1 digitaldaemon.com...Error: AssertError Failure random(10) ?? I don't get it.The code "falls of the end" and doesn't have a return statement. Hence, the compiler inserts an assert. Try compiling with -w.
May 24 2005
On Tue, 24 May 2005 10:30:18 +0300, Lionello Lunesu wrote:"Walter" <newshound digitalmars.com> wrote in message news:d6t52f$1ml0$1 digitaldaemon.com..."clayasaurus" <clayasaurus gmail.com> wrote in message news:d6t0lq$1i1d$1 digitaldaemon.com...Error: AssertError Failure random(10) ?? I don't get it.That's odd. You know this is illegal at compile time. So make it an error. No?Because there are some circumstances in which it is not illegal, and other cases in which the compiler might not be able to work it out without a lot of overhead. I can't think of any, but I believe that Walter has provided examples in the past. -- Derek Parnell Melbourne, Australia 24/05/2005 7:49:33 PM
May 24 2005
"Derek Parnell" <derek psych.ward> wrote in message news:oyymcsk1f6ui.xr10jgtac4ra$.dlg 40tude.net...On Tue, 24 May 2005 10:30:18 +0300, Lionello Lunesu wrote:error."Walter" <newshound digitalmars.com> wrote in message news:d6t52f$1ml0$1 digitaldaemon.com..."clayasaurus" <clayasaurus gmail.com> wrote in message news:d6t0lq$1i1d$1 digitaldaemon.com...Error: AssertError Failure random(10) ?? I don't get it.That's odd. You know this is illegal at compile time. So make it anThe easiest example is: int test(Collection x) { foreach (int i; x) if (foo(i)) return i; } Is foreach guaranteed by the algorithm to never terminate? The compiler can't tell. Being forced to insert a return statement at the end will be confusing and misleading to the maintenance programmer. This, with many pros and cons, was hashed out in great detail a few months ago.No?Because there are some circumstances in which it is not illegal, and other cases in which the compiler might not be able to work it out without a lot of overhead. I can't think of any, but I believe that Walter has provided examples in the past.
May 25 2005
Walter wrote: <snip>The easiest example is: int test(Collection x) { foreach (int i; x) if (foo(i)) return i; } Is foreach guaranteed by the algorithm to never terminate? The compiler can't tell. Being forced to insert a return statement at the end will be confusing and misleading to the maintenance programmer. This, with many pros and cons, was hashed out in great detail a few months ago.Is it me, or are you talking at cross purposes with the rest of us? You give an example of a function that may or may not encounter a return statement. A decent number of us are talking about functions that have no return statements in them at all. Was I imagining it, or did the compiler use to catch these? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 26 2005