ODR:
https://eel.is/c++draft/basic.def.odr
All definition across the program should be the same.
It's hard.
e.g.
// size of Person might be different inside the program.
class Person{
std::string first_;
std::string last_;
# if HAS_MIDDLE_NAME(VAR)
std::string middle_;
#endif
};
ODRV can be embedded anywhere(DSO, static library, or executable)
- Multiple, conflicting definitions of the same symbol in more than one TU.
- Compiling a given header/source file with different compiler settings or #defines
Debug/Release, (no-)RTTI, mismatched preprocessor values, etc. - Overriding operator new/delete in a DSO, but hiding it from the rest of the program.
The passing C++ objects across that DSO boundary. - Multple varying copies of a dependency(e.g. Boost, JPEG, zlib, etc.)
ODRV Behaviors
- Hard to debug
- Hard to reproduce
- Exceptions failing to get caught
- Crashing in the destructor after passing an object across a DSO boundary.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.