Bug 3837 – Safer number literals

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-02-18T13:25:00Z
Last change time
2015-06-09T01:27:38Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-02-18T13:25:35Z
Octal numbers are not common, but sometimes less experienced programmers can add leading zeros to align numbers or for other purposes, and this can cause bugs: int x = 010; This assigns x to value 8. To avoid that bug D can turn leading zeros in syntax errors (for safety with code ported from C to D), and a safer syntax can be introduced for octal literals, for example like in Python3 (or some other syntax can be invented): 0o10 0O10 Optionally D can also turn FP literals like the following into syntax errors: .5 3. To require something like: 0.5 3.0 But this is less important than the octal syntax.
Comment #1 by clugdbug — 2010-03-12T08:25:16Z
*** This issue has been marked as a duplicate of issue 2656 ***