[Issue 3251] New: DecimalFloat literal cannot begin with "08" or "09"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 15 04:51:46 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3251

           Summary: DecimalFloat literal cannot begin with "08" or "09"
           Product: D
           Version: 1.046
          Platform: x86
               URL: http://www.digitalmars.com/d/1.0/lex.html
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: smjg at iname.com


DecimalFloat:
    DecimalDigits .
    DecimalDigits . DecimalDigits
    DecimalDigits . DecimalDigits DecimalExponent
    . Decimal
    . Decimal DecimalExponent
    DecimalDigits DecimalExponent

DecimalDigits:
    DecimalDigit
    DecimalDigit DecimalDigits

DecimalDigit:
    0
    NonZeroDigit
    _

Going by this, floating point literals are the same whether they begin with a 0
or not, unlike integer literals.  Code that illustrates this fact:

----------
pragma(msg, (76).stringof);
pragma(msg, (076).stringof);
pragma(msg, (76.).stringof);
pragma(msg, (076.).stringof);
pragma(msg, (76.543).stringof);
pragma(msg, (076.543).stringof);
pragma(msg, (678.).stringof);
pragma(msg, (0678.).stringof);
pragma(msg, (876.543).stringof);
//pragma(msg, (0876.543).stringof);
----------
76
62
76
76
76.543
76.543
678
678
876.543
----------

However, if the final, commented-out line is reinstated, I get errors:

----------
float_literal.d(10): found '876.543' when expecting ')'
float_literal.d(10): no identifier for declarator .stringof
float_literal.d(10): semicolon expected, not ')'
float_literal.d(10): Declaration expected, not ')'
----------

Presumably, DMD sees the '0' and begins trying to lex it as an Octal, but fails
to recover properly when it stumbles upon the '8'.  But it's strange that other
similar forms compile successfully, such as the aforementioned "0678.", "008."
and "0_9.".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list