788 – Compiler rejects hex floats in the format: HexPrefix HexDigits . HexDigits(opt) with binary-exponent-part required

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 788 - Compiler rejects hex floats in the format: HexPrefix HexDigits . HexDigits(opt) with binary-exponent-part required
Summary: Compiler rejects hex floats in the format: HexPrefix HexDigits . HexDigits(op...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P3 normal
Assignee: Walter Bright
URL:
Keywords: rejects-valid, spec
Depends on:
Blocks:
Reported: 2007年01月02日 21:43 UTC by Vladimir Panteleev
Modified: 2015年10月04日 18:18 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2007年01月02日 21:43:18 UTC
Spec: http://www.digitalmars.com/d/lex.html#floatliteral
Program:
void main()
{
 float f1 = 0x0.;
 float f2 = 0x1.5;
 float f3 = 0x.5;
}
Compiler output:
C:\...\bugs>dmd hexfloat.d
hexfloat.d(3): binary-exponent-part required
hexfloat.d(4): binary-exponent-part required
hexfloat.d(5): binary-exponent-part required
Comment 1 Witold Baryluk 2007年01月10日 14:16:28 UTC
There is also another problem with HexFloat:
0x10f
Is this float (0x10)f, or double (0x10f)?
If, binary-exponent-part is really required, then spec is outdated, and there is no problem:
0x10p0f // float
0x10fp0 // double
"Hexadecimal floats are preceded with a 0x and the exponent is a p or P followed by a decimal number serving as the exponent of 2."
so lexer grammar should be:
HexFloat:
 HexPrefix HexDigits . HexDigits HexExponent
 HexPrefix . HexDigits HexExponent
 HexPrefix HexDigits HexExponent
Comment 2 Walter Bright 2007年02月02日 21:42:15 UTC
The hex exponent is required. I'll fix the doc.
Comment 3 Walter Bright 2007年02月12日 03:36:02 UTC
Fixed DMD 1.005
Comment 4 github-bugzilla 2015年07月07日 11:34:26 UTC
Commit pushed to master at https://github.com/D-Programming-Language/druntime
https://github.com/D-Programming-Language/druntime/commit/fda62efe0f526e8272dfcc47a4cc7c68f5419569
Ignore real pad in core.internal.convert unittest
Change unittest to ignore any pad bytes in a floating point type because
those bits are undefined. Fixes test part of ldc issue #788.
Comment 5 github-bugzilla 2015年10月04日 18:18:48 UTC
Commit pushed to stable at https://github.com/D-Programming-Language/druntime
https://github.com/D-Programming-Language/druntime/commit/fda62efe0f526e8272dfcc47a4cc7c68f5419569
Ignore real pad in core.internal.convert unittest


AltStyle によって変換されたページ (->オリジナル) /