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



--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> 2012-10-22 
09:00:55 UTC ---

It's simple - you basically have



<bb 2>:

  if (Connect_5(D) != 0)

    goto <bb 4>;

  else

    goto <bb 5>;



<bb 3>:

  # occurrence_3 = PHI <0(5), occurrence_1(3)>

  # .MEM_17 = PHI <.MEM_9(D)(5), .MEM_2(3)>

  occurrence_1 = occurrence_3 + 1;

  # .MEM_2 = VDEF <.MEM_17>

  printf ("Sender_Signal  occurrence  %d \n", occurrence_1);

  goto <bb 3>;



and this invokes undefined behavior because occurrence_1 = occurrence_3 + 1

overflows.  Thus GCC is free to do anything.  Fixing the testcase doesn't

fix the code though:



void Sender_signal(int Connect)

{

  unsigned int occurrence = 0;

  int State = 3;

  if (Connect)

    State = 0;

start:

  if (Connect)

    goto start;

  occurrence++;

  if (State != 2)

    __builtin_printf("Sender_Signal occurrence %u\n", occurrence);

  goto start;

}

Reply via email to