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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For goto crossing initialization, C++ makes it a hard error and C only has a
non-default warning (not even in -W), -Wjump-misses-init included in
-Wc++-compat.
As can be seen on:
int
foo (void)
{
  goto a;
  int b = 1;
a:
  b++;
  return b;
}

int
bar (void)
{
  goto a;
  {
    int b = 1;
  a:
    b++;
    return b;
  }
}

int
baz (void)
{
  {
    int b = 1;
    if (1)
      ;
    else
      {
      a:
        b++;
        return b;
      }
  }
  goto a;
}

with g++ or gcc -Wjump-misses-init

Reply via email to