https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Kostya Serebryany from comment #8) > > You haven't responded about the language thing, there is no such thing as > > ODR in C or Fortran, so you shouldn't report it. > > In LLVM, I do not (and should not) know what source language is being > compiled. Sounds like LLVM limitation. > The differences between languages are represented in the linkage types > of the globals. E.g. a regular global in C will not be instrumented at all > unless -fno-common is given. I.e. the difference is not in the source > language > but in the linkage type of the globals. I believe your http://llvm.org/klaus/compiler-rt/blob/0926de35c9357aa1a5c47d3a618d6c72f9e8f085/test/asan/TestCases/Linux/odr-violation.cc example is valid in C, and commonly used (sure, more commonly with functions than with variables, but even with variables). Furthermore, the kind of ODR detection in libasan isn't really ODR detection, you are instead checking if the same global is registered multiple times. GCC intentionally registers local aliases of the globals, so that the same global isn't registered multiple times if it is defined by multiple shared libraries or binary and some shared library - each TU registers the vars local to it, rather than trying to register globals in a completely different shared library. If LLVM uses global symbols instead of local aliases, it is more expensive. You can have aliases/weakrefs etc. to symbols, and those still aren't ODR violations. An ODR violation is IMHO something different, it is the case where you have the same symbol name (but, you'd need to distinguish between globally visible symbols that should be ODR checked and local symbols and/or symbols from languages you don't want to check for it) registered multiple times for multiple addresses. So you'd need to hash based on the symbol name if marked for ODR checking, and check if the same (non-comdat) global isn't registered several times.