ODR part of ISO C standard?
Michael Elizabeth Chastain
mec@shout.net
Tue Aug 19 19:21:00 GMT 2003
This is a question about the One Definition Rule.
I received a gdb bug report (pr gdb/213) which says that gdb behaves badly
on code like this:
/* file gdb213.h */
struct X { struct Y * xx; };
/* file gdb213a.c */
struct Y { double zz; };
#include "gdb213.h"
struct X x_with_double;
int main (void)
{
return 0;
}
/* file gdb213b.c */
struct Y { int zz; };
#include "gdb213.h"
struct X x_with_int;
The complaint is that gdb gets an incorrect type for either
x_with_double or x_with_int.
Obviously this program violates the One Definition Rule.
My question is: is the ODR part of any C standard or not?
That is, is the above program legal under:
ISO/IEC 9899:1990
ISO/IEC 9899:199409
ISO/IEC 9899:1999
?
On a practical note, gcc 3.3.1 with -gdwarf-2 and gdb 5.3
actually does what the user wants (prints correct types for
both x_with_double and x_with_int). gcc with -gstabs+ and
gdb 5.3 does not.
Michael C
More information about the Gcc-help
mailing list