[Bug middle-end/14730] [tree-ssa] ICE on a switch statement with a case which is bigger than the type of switcher

bje at au1 dot ibm dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 1 05:03:00 GMT 2004


------- Additional Comments From bje at au1 dot ibm dot com  2004-04-01 05:02 -------
Subject: PR 14730

I've spent some time looking into this PR.

The problem stems from the fact that the switch's controlling
expression (an expression of type char in the test case) generates a
cast to int early in tree production, but the cast is later optimised
away.  Without the cast, the case label value 256 overflows a char,
becomes a case label value 0 and the case range is miscalculated.
Things quickly go south from there.

T.0_2 = (int)i_1;
switch (T.0_2)
  {
    case 1: goto <L0>;
    case 7: goto <L0>;
    case 10: goto <L0>;
    case 14: goto <L0>;
    case 9: goto <L0>;
    case 256: goto <L0>;
    default : goto <L6>;
  }

After optimisations are applied, the tree looks like this:

switch (i_1)
  {
    case 1: goto <L0>;
    case 7: goto <L0>;
    case 10: goto <L0>;
    case 14: goto <L0>;
    case 9: goto <L0>;
    case 256: goto <L0>;
    default : goto <L6>;
  }

It seems that one of the optimisers is removing the T.0_2 variable and
the cast.  I'll keep digging.

Ben


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14730



More information about the Gcc-bugs mailing list