So I have this code in 2 separate translation units:
// a.cpp
#include
inline int func() { return 5; }
int proxy();
int main() { printf(\"%d\
The simplest way to detect such concerns is to copy all the functions into a single compilation unit (create one temporarily if needed). Any C++ compiler will then be able to detect and report duplicate definitions when compiling that file.
The tools are imperfect.
I think Gold's check will only notice when the symbols have different types or different sizes, which isn't true here (both functions will compile to the same number of instructions, just using a different immediate value).
I'm not sure why -Wodr
doesn't work here, but I think it only works for types, not functions, i.e. it will detect two conflicting definitions of a class type T
but not your func()
.
I don't know anything about ASan's ODR checking.