This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
ODR part of ISO C standard?
- From: Michael Elizabeth Chastain <mec at shout dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 19 Aug 2003 15:21:45 -0400
- Subject: ODR part of ISO C standard?
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