https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64330

            Bug ID: 64330
           Summary: [ASAN] Bogus "AddressSanitizer: odr-violation"
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org,
                    mpolacek at gcc dot gnu.org

I have in a C++ header file ("foo.h"):

class Foo {
 public:
  static const unsigned short   AlignRight;
  static const unsigned short   AlignBottom;
  ...
};

And in its C++ file (foo.cc):

const unsigned short    Foo::AlignRight = 2;
const unsigned short    Foo::AlignTop  = 1;
const unsigned short    Foo::AlignBottom = 2;


I fail to see a reason why that's a violation of the One Definition Rule (ORD),
but ASAN fails with:

==9056==ERROR: AddressSanitizer: odr-violation (0x000004b4dbc0):
  [1] size=2 'AlignRight' foo.cc:23:22
  [2] size=2 'AlignBottom' foo.cc:25:22
These globals were registered at these points:
  [1]:
    #0 0x4daa56 in __asan_register_globals
../../../../libsanitizer/asan/asan_globals.cc:217
    #1 0x4b0c6ac in __libc_csu_init (foo+0x4b0c6ac)
    #2 0x3761c1ecef in __libc_start_main (/lib64/libc.so.6+0x3761c1ecef)

Reply via email to