ODR part of ISO C standard?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux