This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17605] New: Using types as names in classes not always allowed


When using the following code g++ rejects it:

typedef struct _noget {
  int k;
} Noget;

typedef struct _andet {
  Noget * Noget;
} Andet;

pc-32-84:~/Documents/projects/test djn$ g++ test.c -save-temps
In file included from test.c:1:
test.h:10: error: declaration of `Noget*_andet::Noget'
test.h:7: error: changes meaning of `Noget' from `typedef struct
_noget Noget'
pc-32-84:~/Documents/projects/test djn$ 


And it is perfectly legal C code.

BEGIN test.ii
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
# 1 "test.h" 1



typedef struct _noget {
  int k;
} Noget;


typedef struct _andet {
  Noget * Noget;
} Andet;
# 2 "test.c" 2

int main(int argc, char **argv) {

  Noget n;
  Andet a;

  return 0;
}
END test.ii

Environment:
System: Linux ec06 2.4.20-31.9 #1 Tue Apr 13 18:04:23 EDT 2004 i686 i686 i386 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/usr/local

How-To-Repeat:
Compiling the following code:

class Foo {
 public:
  int a;
};

class Bar {
 public:
  Foo * Foo;
};

will also be rejected by g++

-- 
           Summary: Using types as names in classes not always allowed
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: djn at daimi dot au dot dk
                CC: gcc-bugs at gcc dot gnu dot org
 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=17605


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]