gcc -Wc++-compat is quiet about goto crossing/skipping initialization.
g++ says they are errors.

bash$ cat a.c
    void foo(void)
    {
        {
            goto bar;
            int i = 0;          // C++ error
            { int j = 0; }      // Not C++ error (just for comparison)
        bar:
            return;
        }
        goto bar;
    }
bash$ gcc -fsyntax-only -Wc++-compat a.c
bash$ g++ -fsyntax-only a.c
a.c: In function 'void foo()':
a.c:7: error: jump to label 'bar'
a.c:4: error:   from here
a.c:5: error:   crosses initialization of 'int i'
a.c:7: error: jump to label 'bar'
a.c:10: error:   from here
a.c:5: error:   skips initialization of 'int i'


-- 
           Summary: -Wc++-compat does not catch goto past initialization
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: h dot b dot furuseth at usit dot uio dot no
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to