Jump to page: 1 2 3
Thread overview
dmd 125 - is this a bug?
May 23, 2005
clayasaurus
May 23, 2005
Lionello Lunesu
May 23, 2005
clayasaurus
May 23, 2005
clayasaurus
May 23, 2005
Ben Hinkle
May 24, 2005
Lionello Lunesu
May 24, 2005
Derek Parnell
May 24, 2005
clayasaurus
May 24, 2005
Derek Parnell
May 24, 2005
Stewart Gordon
May 24, 2005
Derek Parnell
May 25, 2005
Walter
May 23, 2005
Walter
May 23, 2005
clayasaurus
May 24, 2005
Walter
May 24, 2005
Lionello Lunesu
May 24, 2005
Derek Parnell
May 25, 2005
Walter
May 26, 2005
Stewart Gordon
May 23, 2005
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
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
Lionello Lunesu wrote:
> Maybe it asserts that subsequent values be different :-)
> ....Just kidding... 
> 
> 

bah... rand_seed(getUTCtime(), 0) then : )
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
"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]
> 
> 
>>> 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.

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...
May 24, 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 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.
>
> 


« First   ‹ Prev
1 2 3