https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88983

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think I see the problem: we're evaluating the body of the switch, and cond is
"1" so we're jumping over everything until we find "case 1":

if (1)
  {
    case 1:;
    return <retval> = 1;
  }
else
  {
    default:;
  }

4681     case COND_EXPR:
4682       if (jump_target && *jump_target)

here jump target is "1"

4683         {
4684           /* When jumping to a label, the label might be either in the
4685              then or else blocks, so process then block first in skipping
4686              mode first, and if we are still in the skipping mode at its
end,
4687              process the else block too.  */
4688           r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1),
4689                                             lval, non_constant_p,
overflow_p,
4690                                             jump_target);

we found "case 1" in the then branch, but the next statement was "return", so
we have a new jump_target, which...

4691           if (*jump_target)

...confuses this condition, and we go looking to the else branch...

4692             r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 2),
4693                                               lval, non_constant_p,
overflow_p,
4694                                               jump_target);

...where we crash.

Reply via email to