www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Anyone knows this issue? std/math.d(2759): Error: number '0x1p-1024'

reply Martin Nowak <code+news.digitalmars dawg.eu> writes:
I'm getting this error while trying to build the relase.

std/math.d(2759): Error: number '0x1p-1024' is not representable

I'm getting that while compiling a -m32 (X86) static release phobos
library, but I can't reproduce the error using the same command.
https://github.com/D-Programming-Language/phobos/blob/abb21ab9bcd3857f1567bfde11c2d5d385f5caf0/std/math.d#L2759

Don't even know why the unittests are compiled.
Jun 19 2015
next sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 19 June 2015 at 16:19:05 UTC, Martin Nowak wrote:
 I'm getting this error while trying to build the relase.

 std/math.d(2759): Error: number '0x1p-1024' is not representable

 I'm getting that while compiling a -m32 (X86) static release 
 phobos
 library, but I can't reproduce the error using the same command.
 https://github.com/D-Programming-Language/phobos/blob/abb21ab9bcd3857f1567bfde11c2d5d385f5caf0/std/math.d#L2759

 Don't even know why the unittests are compiled.
See http://forum.dlang.org/post/mjjfjr$nlk$1 digitalmars.com and http://forum.dlang.org/post/fbkyfjfofwaoitaxdply forum.dlang.org
Jun 19 2015
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/19/15 9:34 AM, John Colvin wrote:
 On Friday, 19 June 2015 at 16:19:05 UTC, Martin Nowak wrote:
 I'm getting this error while trying to build the relase.

 std/math.d(2759): Error: number '0x1p-1024' is not representable

 I'm getting that while compiling a -m32 (X86) static release phobos
 library, but I can't reproduce the error using the same command.
 https://github.com/D-Programming-Language/phobos/blob/abb21ab9bcd3857f1567bfde11c2d5d385f5caf0/std/math.d#L2759


 Don't even know why the unittests are compiled.
See http://forum.dlang.org/post/mjjfjr$nlk$1 digitalmars.com and http://forum.dlang.org/post/fbkyfjfofwaoitaxdply forum.dlang.org
Links taken from the new forum interface seem useless. Neither of these go nowhere relevant (nor does the one posted by Martin). I'm using the vertical split layout if that matters. In related news: the fact that I need to point to the post I want to see with Ctrl-Up and Ctrl-Down, and THEN press Enter like an idiot to see it is definitely not working out for me. I understand it saves bandwidth, but if most bandwidth savings come from nobody using the interface then it's no gain to anyone. Please have the message viewer follow the list focus. cc Vladimir Thanks, Andrei
Jun 19 2015
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 19 June 2015 at 16:59:20 UTC, Andrei Alexandrescu 
wrote:
 On 6/19/15 9:34 AM, John Colvin wrote:
 On Friday, 19 June 2015 at 16:19:05 UTC, Martin Nowak wrote:
 [...]
See http://forum.dlang.org/post/mjjfjr$nlk$1 digitalmars.com and http://forum.dlang.org/post/fbkyfjfofwaoitaxdply forum.dlang.org
Links taken from the new forum interface seem useless. Neither of these go nowhere relevant (nor does the one posted by Martin). I'm using the vertical split layout if that matters.
This seems to be specific to the vertical-split layout. Works fine in the other 3 layouts.
Jun 19 2015
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/19/15 9:18 AM, Martin Nowak wrote:
 I'm getting this error while trying to build the relase.

 std/math.d(2759): Error: number '0x1p-1024' is not representable

 I'm getting that while compiling a -m32 (X86) static release phobos
 library, but I can't reproduce the error using the same command.
 https://github.com/D-Programming-Language/phobos/blob/abb21ab9bcd3857f1567bfde11c2d5d385f5caf0/std/math.d#L2759

 Don't even know why the unittests are compiled.
This is happening on my older CentOS as well, it's a problem in the C library. I suggest we just version those tests. -- Andrei
Jun 19 2015
parent reply Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 06/19/2015 06:54 PM, Andrei Alexandrescu wrote:
 This is happening on my older CentOS as well, it's a problem in the C
 library. I suggest we just version those tests. -- Andrei
Even more worrisome, I don't understand why dmd is compiling the unittests at all. Might be related to https://issues.dlang.org/show_bug.cgi?id=14431 or https://issues.dlang.org/show_bug.cgi?id=14508.
Jun 20 2015
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/20/15 2:30 AM, Martin Nowak wrote:
 On 06/19/2015 06:54 PM, Andrei Alexandrescu wrote:
 This is happening on my older CentOS as well, it's a problem in the C
 library. I suggest we just version those tests. -- Andrei
Even more worrisome, I don't understand why dmd is compiling the unittests at all.
I think it's just tokenizing them that triggers the errors. -- Andrei
Jun 20 2015
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 6/19/2015 9:18 AM, Martin Nowak wrote:
 I'm getting this error while trying to build the relase.

 std/math.d(2759): Error: number '0x1p-1024' is not representable

 I'm getting that while compiling a -m32 (X86) static release phobos
 library, but I can't reproduce the error using the same command.
 https://github.com/D-Programming-Language/phobos/blob/abb21ab9bcd3857f1567bfde11c2d5d385f5caf0/std/math.d#L2759

 Don't even know why the unittests are compiled.
Which C runtime are you using? The math functions in C runtimes are often inadequate.
Jun 20 2015
next sibling parent Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 06/20/2015 09:52 AM, Walter Bright wrote:
 Which C runtime are you using? The math functions in C runtimes are
 often inadequate.
Debian 7.4, there is nothing I can do to avoid glibc.
Jun 20 2015
prev sibling parent reply Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 06/20/2015 09:52 AM, Walter Bright wrote:
 
 Which C runtime are you using? The math functions in C runtimes are
 often inadequate.
So we now call the host's C library to perform constant folding/CTFE of exp? This is a point for Iain's proposal to use a high precision floating point implementation in the compiler to avoid machine/platform differences.
Jun 20 2015
parent reply Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 20 Jun 2015 11:35, "Martin Nowak via Digitalmars-d" <
digitalmars-d puremagic.com> wrote:
 On 06/20/2015 09:52 AM, Walter Bright wrote:
 Which C runtime are you using? The math functions in C runtimes are
 often inadequate.
So we now call the host's C library to perform constant folding/CTFE of
exp?
 This is a point for Iain's proposal to use a high precision floating
 point implementation in the compiler to avoid machine/platform
differences. I thought dmd used the C library implementations for all intrinsics via CTFE, not just exp? In any case, isn't the problem you are seeing related to the conversion of string to float? Which again dmd is at the mercy of the C library implementation to handle correctly.
Jun 20 2015
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 6/20/2015 2:48 AM, Iain Buclaw via Digitalmars-d wrote:
 On 20 Jun 2015 11:35, "Martin Nowak via Digitalmars-d"
 <digitalmars-d puremagic.com <mailto:digitalmars-d puremagic.com>> wrote:
  >
  > On 06/20/2015 09:52 AM, Walter Bright wrote:
  > >
  > > Which C runtime are you using? The math functions in C runtimes are
  > > often inadequate.
  >
  > So we now call the host's C library to perform constant folding/CTFE of exp?
  > This is a point for Iain's proposal to use a high precision floating
  > point implementation in the compiler to avoid machine/platform differences.

 I thought dmd used the C library implementations for all intrinsics via CTFE,
 not just exp?

 In any case, isn't the problem you are seeing related to the conversion of
 string to float? Which again dmd is at the mercy of the C library
implementation
 to handle correctly.
The code is the following, in lexer.c: errno = 0; (void)Port::strtod((char *)stringbuffer.data, NULL); if (errno == ERANGE) { const char *suffix = (result == TOKfloat32v || result == TOKimaginary32v) ? "f" : ""; error(scanloc, "number '%s%s' is not representable", (char *)stringbuffer.data, suffix); } The point of the Port:: code is to correct for inadequacies of various C standard library implementations, in this case Debian 7.4. Apparently we need to roll our own version of strtod() and put it in Port.
Jun 20 2015
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 6/20/2015 3:06 AM, Walter Bright wrote:
 Apparently we need to roll our own version of strtod() and put it in Port.
We already do our own strtold(), so it should be straightforward.
Jun 20 2015
parent reply Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 06/20/2015 12:06 PM, Walter Bright wrote:
 On 6/20/2015 3:06 AM, Walter Bright wrote:
 Apparently we need to roll our own version of strtod() and put it in
 Port.
We already do our own strtold(), so it should be straightforward.
Thanks, I'll work on a fix.
Jun 20 2015
parent reply Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 06/20/2015 02:00 PM, Martin Nowak wrote:
 On 06/20/2015 12:06 PM, Walter Bright wrote:
 On 6/20/2015 3:06 AM, Walter Bright wrote:
 Apparently we need to roll our own version of strtod() and put it in
 Port.
We already do our own strtold(), so it should be straightforward.
Thanks, I'll work on a fix.
I can't use the strtold_dm from the backend, b/c it's not available for the other compilers, and AFAIU licensing doesn't allow me to move it to the frontend.
Jun 20 2015
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 6/20/2015 5:16 AM, Martin Nowak wrote:
 I can't use the strtold_dm from the backend, b/c it's not available for
 the other compilers, and AFAIU licensing doesn't allow me to move it to
 the frontend.
Hmm. Perhaps google for similar code that would be available? Or submit a bug report to the Debian folks?
Jun 20 2015
parent "Martin Nowak" <code dawg.eu> writes:
On Saturday, 20 June 2015 at 17:04:48 UTC, Walter Bright wrote:
 On 6/20/2015 5:16 AM, Martin Nowak wrote:
 I can't use the strtold_dm from the backend, b/c it's not 
 available for
 the other compilers, and AFAIU licensing doesn't allow me to 
 move it to
 the frontend.
Hmm. Perhaps google for similar code that would be available?
Might work, as the issue dates back to 2013, I'd say we skip it for this release and fix it independently.
Jun 20 2015
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 6/20/2015 5:16 AM, Martin Nowak wrote:
 On 06/20/2015 02:00 PM, Martin Nowak wrote:
 On 06/20/2015 12:06 PM, Walter Bright wrote:
 On 6/20/2015 3:06 AM, Walter Bright wrote:
 Apparently we need to roll our own version of strtod() and put it in
 Port.
We already do our own strtold(), so it should be straightforward.
Thanks, I'll work on a fix.
I can't use the strtold_dm from the backend, b/c it's not available for the other compilers, and AFAIU licensing doesn't allow me to move it to the frontend.
Ironically, this just appeared: https://www.reddit.com/r/programming/comments/3aif1a/visual_c_strtod_still_broken/
Jun 20 2015
prev sibling parent reply Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 20 June 2015 at 12:06, Walter Bright via Digitalmars-d <
digitalmars-d puremagic.com> wrote:

 On 6/20/2015 2:48 AM, Iain Buclaw via Digitalmars-d wrote:

 On 20 Jun 2015 11:35, "Martin Nowak via Digitalmars-d"
 <digitalmars-d puremagic.com <mailto:digitalmars-d puremagic.com>> wrote:
  >
  > On 06/20/2015 09:52 AM, Walter Bright wrote:
  > >
  > > Which C runtime are you using? The math functions in C runtimes are
  > > often inadequate.
  >
  > So we now call the host's C library to perform constant folding/CTFE
 of exp?
  > This is a point for Iain's proposal to use a high precision floating
  > point implementation in the compiler to avoid machine/platform
 differences.

 I thought dmd used the C library implementations for all intrinsics via
 CTFE,
 not just exp?

 In any case, isn't the problem you are seeing related to the conversion of
 string to float? Which again dmd is at the mercy of the C library
 implementation
 to handle correctly.
The code is the following, in lexer.c: errno = 0; (void)Port::strtod((char *)stringbuffer.data, NULL); if (errno == ERANGE)
Ah yes, that brings back memories of fixing GDC to set errno = ERANGE if casting the result from 160bits down returns Infinity. Can we make this a boolean check removing the need for me to explicitly set errno?
Jun 20 2015
parent reply Martin Nowak <code+news.digitalmars dawg.eu> writes:
On 06/20/2015 01:35 PM, Iain Buclaw via Digitalmars-d wrote:
 Can we make this a boolean check removing the need for me to explicitly set
 errno?
The function returns a float, so errno seems like the better choice.
Jun 20 2015
parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 20 June 2015 at 14:03, Martin Nowak via Digitalmars-d <
digitalmars-d puremagic.com> wrote:

 On 06/20/2015 01:35 PM, Iain Buclaw via Digitalmars-d wrote:
 Can we make this a boolean check removing the need for me to explicitly
set
 errno?
The function returns a float, so errno seems like the better choice.
It's at this point which I say it's a longdouble for GDC. Incase I need to remind people that there are no uses of native FP whatsoever in my compiler. :-)
Jun 20 2015