incomplete enums in classes
Stephane Chauveau
s.chauveau@chello.nl
Mon Jun 3 13:52:00 GMT 2002
I found a problem in gdb 5.2 when debugging g++ programs.
Enum types declared without a name within a class are incomplete.
Consider the following program:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
enum TYPE1 { V1 } ;
typedef enum { V2 } TYPE2 ;
class FOO {
public:
enum TYPE3 { V3 } ; typedef enum { V4 } TYPE4 ;
int v ; } ;
enum TYPE1 a ; TYPE2 b ; enum FOO::TYPE3 c ; FOO::TYPE4 d ;
int
main(void)
{
a = V1 ; b = V2 ; c = FOO::V3 ; d = FOO::V4 ; }
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The problem appears in last line of the following gdb session.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Breakpoint 1, main () at test.cxx:23
23 a = V1 ; (gdb) s
24 b = V2 ; (gdb) s
25 c = FOO::V3 ; (gdb) s
26 d = FOO::V4 ; (gdb) s
0x080484f0 27 }
(gdb) p a
$1 = V1
(gdb) p b
$2 = V2
(gdb) p c
$3 = V3
(gdb) p d
$4 = <incomplete type>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I also found that giving a name to the enum solves the problem:
typedef enum _TYPE4 { V4 } TYPE4 ;
If this is feature then I would expect to see the same behavior
with the 'incomplete' type TYPE2.
More information about the Gdb
mailing list