boostorg/filesystem

ODR violations in boost::filesystem::path

frankmiller opened this issue · 3 comments

There are a number of inline member functions in boost::filesystem::path that have different implementations depending on the definition of BOOST_FILESYSTEM_VERSION. When compiling boost.filesystem, BOOST_FILESYSTEM_VERSION is always set to 4. If a program uses boost.filesystem with BOOST_FILESYSTEM_VERSION set to 3, which is the default, then I believe this is an ODR violation because the program now has multiple definitions of the same function that do not consist of the same sequence of tokens.

Duplicates #243.

Yes, this is formally an ODR violation. In practice, though, it works due to forced inlining of these methods. This will get resolved when v3 is dropped.

For the record, there is no inlining in a debug build. Also, I suspect LTO is interacting with inlining in unexpected ways, at least with msvc. I'm happy to resolve the issues I'm seeing on my end by moving to version 4. I just wanted to make sure the upstream maintainers were aware.

Yes, debug build needs fixing.