David Brown <david.br...@hesbynett.no> writes:

> Assuming I'm correct here, then perhaps there could be a warning or
> error message that is triggered by breaking the ODR, and which could
> be enabled automatically by the -flto flag.  Perhaps existing checking
> mechanisms from C++ can be used here.

It's a good idea but unfortunately I know of no reliable checking
mechanisms for ODR violations in C++.  The standard says that
implementations are not required to diagnose violations, which is
standardese for "we don't know how to check this either."

The gold linker tries pretty hard if you use the
--detect-odr-violations option, but the option, besides measurably
increasing link time, and only working on unoptimized code,
unfortunately has false negatives.  I do not know of any way to avoid
the false negatives without introducing an unacceptable number of
false positives.

Ian

Reply via email to