View mode: basic / threaded / horizontal-split · Log in · Help
May 04, 2009
could someone check this on another system?
The attached (er. Can't seem to attach the file, I'll e-mail it to anyone 
who's willing to take a look) has a bug on WinXP DMD 1.040. I can't seem 
to reduce it at all as anything but trivial changes (like removing dead code) 
seems to make the bug vanish.

The short description is I have some code that looks something like this:


bool Foo()
{
  bool ret = true;
  writef(ret,'\n');
  return ret;
}

unittest
{
   auto ret = Foo();
   writef(ret,'\n');
   assert(ret);
}

output:

true
false
Assert Failed
May 04, 2009
Re: could someone check this on another system?
BCS wrote:
> The attached (er. Can't seem to attach the file, I'll e-mail it to 
> anyone who's willing to take a look) has a bug on WinXP DMD 1.040. I 
> can't seem to reduce it at all as anything but trivial changes (like 
> removing dead code) seems to make the bug vanish.
> 
> The short description is I have some code that looks something like this:
> 
> 
> bool Foo()
> {
>   bool ret = true;
>   writef(ret,'\n');
>   return ret;
> }
> 
> unittest
> {
>    auto ret = Foo();
>    writef(ret,'\n');
>    assert(ret);
> }
> 
> output:
> 
> true
> false
> Assert Failed

Prints
true
true
on Fedora-10, dmd v1.042
May 04, 2009
Re: could someone check this on another system?
Reply to Benjamin,

> The attached (er. Can't seem to attach the file, I'll e-mail it to
> anyone who's willing to take a look) has a bug on WinXP DMD 1.040. I
> can't seem to reduce it at all as anything but trivial changes (like
> removing dead code) seems to make the bug vanish.
> 
> The short description is I have some code that looks something like
> this:
> 
> bool Foo()
> {
> bool ret = true;
> writef(ret,'\n');
> return ret;
> }
> unittest
> {
> auto ret = Foo();
> writef(ret,'\n');
> assert(ret);
> }
> output:
> 
> true
> false
> Assert Failed

I've posted the code here:

http://smplsite.com/filebox/error.zip
May 04, 2009
Re: could someone check this on another system?
Reply to Georg,

> BCS wrote:
> 
>> The attached (er. Can't seem to attach the file, I'll e-mail it to
>> anyone who's willing to take a look) has a bug on WinXP DMD 1.040. I
>> can't seem to reduce it at all as anything but trivial changes (like
>> removing dead code) seems to make the bug vanish.
>> 
>> The short description is I have some code that looks something like
>> this:
>> 
>> bool Foo()
>> {
>> bool ret = true;
>> writef(ret,'\n');
>> return ret;
>> }
>> unittest
>> {
>> auto ret = Foo();
>> writef(ret,'\n');
>> assert(ret);
>> }
>> output:
>> 
>> true
>> false
>> Assert Failed
> Prints
> true
> true
> on Fedora-10, dmd v1.042

As I said, it's something like the above (but not exactly) and even minor 
changes make it vanish so it's no surprise that exact code works.
May 04, 2009
Re: could someone check this on another system?
"BCS" <none@anon.com> wrote in message 
news:a6268ff56558cb9ab074256fbe@news.digitalmars.com...
> The attached (er. Can't seem to attach the file, I'll e-mail it to anyone 
> who's willing to take a look) has a bug on WinXP DMD 1.040. I can't seem 
> to reduce it at all as anything but trivial changes (like removing dead 
> code) seems to make the bug vanish.
>
> The short description is I have some code that looks something like this:
>
>
> bool Foo()
> {
>   bool ret = true;
>   writef(ret,'\n');
>   return ret;
> }
>
> unittest
> {
>    auto ret = Foo();
>    writef(ret,'\n');
>    assert(ret);
> }
>
> output:
>
> true
> false
> Assert Failed
>


Prepending the following to the above:

import std.stdio;
void main() {}

I got the following on WinXP 32-bit DMD 1.041:
true
true
May 04, 2009
Re: could someone check this on another system?
Reply to Nick,

> "BCS" <none@anon.com> wrote in message
> news:a6268ff56558cb9ab074256fbe@news.digitalmars.com...
> 
>> The attached (er. Can't seem to attach the file, I'll e-mail it to
>> anyone who's willing to take a look) 
>
> I got the following on WinXP 32-bit DMD 1.041:
> true
> true

try the version that actuly has the bug:

http://smplsite.com/filebox/error.zip
May 04, 2009
Re: could someone check this on another system?
"BCS" <ao@pathlink.com> wrote in message 
news:78ccfa2d3f7098cb9acac6a471c6@news.digitalmars.com...
> Reply to Nick,
>
>> "BCS" <none@anon.com> wrote in message
>> news:a6268ff56558cb9ab074256fbe@news.digitalmars.com...
>>
>>> The attached (er. Can't seem to attach the file, I'll e-mail it to
>>> anyone who's willing to take a look)
>>
>> I got the following on WinXP 32-bit DMD 1.041:
>> true
>> true
>
> try the version that actuly has the bug:
>
> http://smplsite.com/filebox/error.zip
>

Ok, WinXP 32-bit, and on both 1.040 and 1.041 (byte-for-byte identical 
output on both), my output from go.bat was:

----------------------
D:\DevProject\Test\D\NewsgroupRequest\error>del *.obj

D:\DevProject\Test\D\NewsgroupRequest\error>dmd -c -unittest -Icairod 
by_loop.d
[<%lg,%lg>|<%lg,%lg>]

D:\DevProject\Test\D\NewsgroupRequest\error>dmd -c -unittest -Icairod 
output.d
[<%lg,%lg>|<%lg,%lg>]

D:\DevProject\Test\D\NewsgroupRequest\error>dmd -c -unittest -Icairod 
graph.d
[<%lg,%lg>|<%lg,%lg>]

D:\DevProject\Test\D\NewsgroupRequest\error>dmd -c -unittest -Icairod geom.d
[<%lg,%lg>|<%lg,%lg>]

D:\DevProject\Test\D\NewsgroupRequest\error>dmd -c -unittest -Icairod 
utmain.d

D:\DevProject\Test\D\NewsgroupRequest\error>dmd utmain.obj by_loop.obj 
output.obj graph.obj geom.obj cairo.lib

D:\DevProject\Test\D\NewsgroupRequest\error>utmain
>>true
>>false
>>true
>>true
>>true
>>true
>>true
>>true
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>true
>>true
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>true
>>true
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>true
>>true
---true
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>false
>>true
>>true
>>false
>>false
>>false
>>false
>>true
>>false
>>false
>>false
>>false
>>true
>>false
>>false
>>false
>>false
>>true
>>false
>>false
>>false
>>false
>>true
----------------------
May 04, 2009
Re: could someone check this on another system?
Reply to Nick,

> Ok, WinXP 32-bit, and on both 1.040 and 1.041 (byte-for-byte identical
> output on both), my output from go.bat was:
> 
...

>>> true
> ---true


Hmm. IIRC my home box gave:

>> true
--- false

but I just ran it on my work  boxes and got:

>> false
--- false

I'll have to recheck the home machine. With a bit more digging it seems that 
right now I'm getting an almost equal error that writef was hiding by rounding. 
I've already got a fuzzy equal so I guess I just need to do some tuning.
May 05, 2009
Re: could someone check this on another system?
BCS Wrote:

> I've posted the code here:
> 
> http://smplsite.com/filebox/error.zip
> 

	auto r = (rp == Point(-.5,1.5));
	writef("---%s\n", r);
	assert(r, "++"~rp.toString);

Is this it?
May 05, 2009
Re: could someone check this on another system?
Reply to Kagamin,

> BCS Wrote:
> 
>> I've posted the code here:
>> 
>> http://smplsite.com/filebox/error.zip
>> 
> auto r = (rp == Point(-.5,1.5));
> writef("---%s\n", r);
> assert(r, "++"~rp.toString);
> Is this it?
> 


Yes that's the spot that was (is?) generating an error. I'm not so sure anymore 
as my system is no longer reproing but I seem to recall that it was printing 
out true inside the opEquals function but false outside.

BTW the first function in that file had a bug and should be:

//Usable AlmostEqual function
bool ULP(T)(T A, T B, uint maxUlps)
{
	if(A == B) return true;
	static if(is(T == float)) { alias int Tint; Tint bound = 0x8000_0000; }
	else static if(is(T == double)) { alias long Tint; Tint bound = 0x8000_0000_0000_0000; 
}
	else static assert(false, "only float or double can be used, not "~T.stringof);
		
	// Make sure maxUlps is non-negative and small enough that the
	// default NAN won't compare as equal to anything.
	assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024);

	auto aInt = *cast(Tint*)&A;
	// Make aInt lexicographically ordered as a twos-complement int
	if (aInt < 0) aInt = bound - aInt;

	// Make bInt lexicographically ordered as a twos-complement int
	auto bInt = *cast(Tint*)&B;
	if (bInt < 0) bInt = bound - bInt;

	auto ulp = abs(aInt - bInt); 
	if (ulp <= maxUlps) return true;
	return false;
}
Top | Discussion index | About this forum | D home