[Issue 10382] New: Regression (2.059): ICE when catching illegal type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 16 07:56:20 PDT 2013


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

           Summary: Regression (2.059): ICE when catching illegal type
           Product: D
           Version: future
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ice
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: doob at me.com


--- Comment #0 from Jacob Carlborg <doob at me.com> 2013-06-16 07:56:19 PDT ---
The following results in a segmentation fault:

void main ()
{
    try
    {
        int b = 3;
    }

    catch (int a) { }
}

I think the problem is that the compiler doesn't perform semantic analyzes in
all cases on catch statements.

https://github.com/D-Programming-Language/dmd/blob/master/src/statement.c#L4561

If the if-statement and return is removed from statement.c#L4561 everything
works correctly. This guard for the semantic analyze was added for a reason, in
this commit:

c28df7d72e72f6c0c3bb389538afb1871b7ad15c

DMD checks the "type" instance variable to determine if the semantic analyze
has been run for a given statement. The problem in this case is this piece of
code:

https://github.com/D-Programming-Language/dmd/blob/master/src/parse.c#L4641

This will set "type" on the Catch statement in the constructor. When the
compiler then comes to run the semantic analyze on the Catch statement it
thinks it's already been run. To me it seems it's not reliable to check "type"
if the semantic analyze has been run. Perhaps add a new flag?

The ICE will only happen if there's some code in the try-statement. If I remove
the code in the try-statement I can basically put whatever I want in the
catch-statement, that is syntactically correct, without the compiler
complaining. This compiles fine:

void main ()
{
    try
    {

    }

    catch (int sdf)
    {
        asd;
        a * + 4;
        a b;
    }
}

I'm a bit surprised that this regression has been available for so long. I
actually only found it by inspecting the source code of DMD. Then I was able to
produce a test case. Seems people always write their catch-statements correctly
:)

-- 
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