Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1015 (closed defect: fixed)

Opened 4 months ago

Last modified 3 months ago

Float printing bug

Reported by: revcompgeek Assigned to: sean
Priority: major Milestone: 0.99.6
Component: Core Functionality Version: 0.99.5 Jascha
Keywords: Cc: afb, jason.james.house@gmail.com

Description

Floats do not print normally, but doubles do. Example:

module floattest;

import tango.io.Stdout;

void main(){
	float x = 3.14;
	double y = 3.14;
	Stdout(x).newline;
	Stdout(y).newline;
	Stdout(cast(double)x).newline;
}

The output I get on my system (which is Mac OS 10.4 PPC compiling with DSSS) is:

2.14
3.14
3.14

Attachments

tango-stdarg.patch (1.1 kB) - added by afb on 04/06/08 04:12:24.
tango-stdarg.patch

Change History

04/06/08 00:02:58 changed by jhouse

  • cc set to jason.james.house@gmail.com.

I've also seen some strange floating point effects...

int movesLeft = 60; ... formatln("\tUsed {}, {} remaining for {} moves", moveTime, totalTime, movesLeft-1); }

Output:

Used -0.11e-18, 2.67 remaining for 1073741824 moves

It seems that the floating point output somehow causes corruption of later output as well.

04/06/08 03:35:19 changed by larsivi

  • cc changed from jason.james.house@gmail.com to afb, jason.james.house@gmail.com.

Anders, could you be goaded into looking at this?

(follow-up: ↓ 4 ) 04/06/08 03:54:26 changed by afb

Here is what I get, on Mac OS X 10.4.

i386:

2.14
3.14
3.14

ppc:

3.68e+19
3.14
3.14

So something is not right...

(in reply to: ↑ 3 ) 04/06/08 03:55:10 changed by afb

Replying to afb:

Here is what I get, on Mac OS X 10.4.

Oops, switched i386/ppc output around...

04/06/08 04:11:46 changed by afb

This bug, like the ones before it, is because it plays with _argptr instead of using std.stdarg.

If I change the "version (X86_64)" in tango/text/convert/Layout.d to include "version (darwin)", then it prints the expected output for both -arch ppc and -arch i386 when compiled with GDC...

We have discussed this issue before, and the DMD "specification" of va_list just isn't portable.

04/06/08 04:12:24 changed by afb

  • attachment tango-stdarg.patch added.

tango-stdarg.patch

04/06/08 07:31:23 changed by larsivi

I agree that it seems unlikely that GDC will follow the spec in our time, and thus we'll need the workaround/hack.

(follow-up: ↓ 8 ) 04/06/08 08:26:47 changed by jhouse

I probably should have added that I'm not using a Mac. I have a windows x86 running Ubuntu 7.10.

(in reply to: ↑ 7 ) 04/06/08 10:06:22 changed by afb

Replying to jhouse:

I probably should have added that I'm not using a Mac. I have a windows x86 running Ubuntu 7.10.

Should test it with GDC in MinGW too, but I suspect that it really should have been version(GNU) ?

04/06/08 12:10:59 changed by larsivi

I intend to use GNU when I get around to this.

04/08/08 12:34:06 changed by larsivi

  • status changed from new to closed.
  • resolution set to fixed.

(In [3420]) Make X86_64 formatting hack apply to all platforms when using GDC. Man, GDC sucks. closes #1015