If the project is completely modular (i.e. never uses #include ), then most of the random ODR violations will disappear. Most random ODR violations occur due to the nature of #include : including a global variable with definition, etc. Or two-phase problems of searching for a template, where two files contain the same template, but because each of them is included before this template, the definition of two templates is different.
However, this does nothing to prevent less "random" ODR violations. Since "the same object" is defined by its name, and the name of the object has nothing to do with the module from which it was exported, two modules can provide different definitions of the same object. So basically the names of the conflicts.
This becomes only a compilation (i.e. the required diagnostics) if one translation unit imports both of these modules. If two separate translation units include one of the modules with different definitions, then the program as a whole still violates ODR, but there is no need for diagnostics.
Thus, even in a fully modular code base, ODR can still be violated.
source share