July 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10703

           Summary: Front-end code removal "optimisation" with try/catch
                    blocks produces wrong codegen
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: ibuclaw@ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-07-23 07:28:21 PDT ---
Simple example that compiles with dmd but runtime segfaults at the location of 'goto'.  This is also uncompilable with gdc, and would cause an ICE if not for working around the problem as per https://github.com/D-Programming-Language/dmd/pull/2176.


void main()
{
  int a;
  goto L2;    // BOOM!

  try { }
  catch (Exception e) {
L2: ;
      a += 100;
  }
  assert(a == 100);
}


The most obvious wrong thing about code like this is that it skips over the initialisation of 'e', which is a direct violation of the spec for GotoStatements.  But if the code is actively removed from the front-end, that makes checking this violation impossible in lower layers of the code generation routines.  So we need to be able to achieve this in the front-end.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10703



--- Comment #1 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-07-23 07:32:05 PDT ---
(In reply to comment #0)
> 
> void main()
> {
>   int a;
>   goto L2;    // BOOM!
> 
>   try { }
>   catch (Exception e) {
> L2: ;
>       a += 100;
>   }
>   assert(a == 100);
> }
> 

For clarification, the front-end currently passes this to the back-end.

void main()
{
  int a;
  goto L2;    // BOOM!

  assert(a == 100);
}

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