[cfe-commits] [PATCH] Crash when constant folding switch statements (Bug 11656)

David Blaikie dblaikie at gmail.com
Sun Jan 15 16:04:52 PST 2012


Test case would be nice - and, naively: is there any reason this
wouldn't be fixed up by the constant-folding code? (perhaps it's
better the way you've fixed it, but I am curious - leaving cases
without switches around when constant folding seems a bit suspect/odd)

On Sun, Jan 15, 2012 at 3:36 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
> Bug 11656 demonstrates a crash in the code generator on the following
> (reduced) code:
>
> int main(void){
>        int x = 0;
>        int i = 0;
>        switch (4) {
>                case 4: do {i++; x++; int x = 5; case 5: x++;} while (i < 3);
>        }
>        return x;
> }
>
> The crash happens because we omit the switch and case constructs
> during constant folding, and simply perform the do loop.  However, the
> do loop still has a case statement in it, but no enclosing switch
> (that the CG recognizes).
>
> I've attached a patch that should address this issue -- if there's no
> enclosing switch instance available for a case statement, we generate
> the sub statement without the accompanying case.
>
> HTH!
>
> ~Aaron
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list