D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3628 - can't cast null to int
Summary: can't cast null to int
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2009-12-17 13:41 UTC by Vladimir Panteleev
Modified: 2014-04-18 09:12 UTC (History)
2 users (show)

See Also:


Attachments
Proposed patch (792 bytes, patch)
2009-12-17 13:41 UTC, Vladimir Panteleev
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2009-12-17 13:41:18 UTC
Created attachment 527 [details]
Proposed patch

Testcase:

void main()
{
    int a = cast(int)null;
}

DMD 1.046 compiles fine.
DMD 1.047 outputs: 
test.d(3): Error: Integer constant expression expected instead of null
test.d(3): Error: Integer constant expression expected instead of null

Attaching proposed patch (needs review).
Comment 1 Vladimir Panteleev 2009-12-17 13:49:58 UTC
I forgot to mention... this bug breaks the DFL library ( http://www.dprogramming.com/dfl.php ). Makes me wonder if I'm the only library's user left.
Comment 2 Leandro Lucarella 2009-12-29 08:56:03 UTC
http://www.dsource.org/projects/dmd/changeset/316
Comment 3 Leandro Lucarella 2009-12-29 08:58:06 UTC
http://www.dsource.org/projects/dmd/changeset/316
Comment 4 Walter Bright 2009-12-31 11:18:33 UTC
Fixed dmd 1.054