https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888
--- Comment #12 from Kostya Serebryany <kcc at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #9) > (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 But for this example in C the globals will not get instrumented, unless -fno-common is given. > , 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. But these again should not be instrumented by asan at all. No? > > 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. Never seen a case like this ("registered multiple times for multiple addresses"). Can you give an example? >> 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.