D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4949 - ICE on invalid static if using value of 'this'
Summary: ICE on invalid static if using value of 'this'
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2010-09-27 10:29 UTC by Iain Buclaw
Modified: 2015-06-09 05:10 UTC (History)
2 users (show)

See Also:


Attachments
catch functions returning CANT_INTEPRET_EXP (767 bytes, patch)
2010-09-27 10:29 UTC, Iain Buclaw
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Iain Buclaw 2010-09-27 10:29:25 UTC
Created attachment 777 [details]
catch functions returning CANT_INTEPRET_EXP

testcase:

class A
{
    bool delegate() dg;
    void B()
    {
        static if ( dg() )
            should error graciously;
    }
}

Produces:
ice.d(6): Error: value of 'this' is not known at compile time
Segmentation fault (core dumped)

Catching it in gdb, occurs in interpret.c at CallExp::interpret, around line
2720. A few assignments, no checking whether or not any returned
EXP_CANT_INTERPRET.

Currently rebuilding using the attached change...
Comment 1 Iain Buclaw 2010-09-27 10:38:40 UTC
Tested, I now get:

ice.d(6): Error: value of 'this' is not known at compile time
ice.d(6): Error: expression this.dg() is not constant or does not evaluate to a bool


Which is correct, and fixes the ICE.

Regards
Comment 2 Walter Bright 2010-10-08 14:12:57 UTC
http://www.dsource.org/projects/dmd/changeset/710