www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6095] New: switch executes code it shouldn't

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

           Summary: switch executes code it shouldn't
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: braddr puremagic.com



---
From runnable/sdtor.d, test 51:

int A51_a;

struct A51
{
    ~this() { ++A51_a; }
}

void test51() // an excerpt from the full test
{
  // should fail to build, no case 1 and no default
  A51_a = 0; { if (0) final switch(1) A51 a;        } assert(A51_a == 0);

  // should be 0, there's no flow that should involve a being instantiated
  // or destroyed
  A51_a = 0; { if (1) switch(1) { A51 a; default: } } assert(A51_a == 1);
}

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