www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10703] New: Front-end code removal "optimisation" with try/catch blocks produces wrong codegen

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 23 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10703





 
 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: -------
Jul 23 2013