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

            Bug ID: 62202
           Summary: g++ does not accept typedef-name after struct even if
                    -fpermissive is used
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugzi...@poradnik-webmastera.com

gcc silently compiles this, even with -Wall -Wextra -pedantic:

struct test_s { int n; };
typedef struct test_s test_t;
typedef struct test_t* something_t;
int main() { return 0; }

g++ reports following error even if -fpermissive option is used:
test.c:3:16: error: using typedef-name ‘test_t’ after ‘struct’
 typedef struct test_t* something_t;
                ^
test.c:2:23: note: ‘test_t’ has a previous declaration here
 typedef struct test_s test_t;
                       ^
test.c:3:35: error: invalid type in declaration before ‘;’ token
 typedef struct test_t* something_t;
                                   ^

Please extend permissive mode to accept such case too. Also consider printing
warning when compiling C code.

Reply via email to