Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODR violations in boost::filesystem::path #279

Closed
frankmiller opened this issue Feb 2, 2023 · 3 comments
Closed

ODR violations in boost::filesystem::path #279

frankmiller opened this issue Feb 2, 2023 · 3 comments

Comments

@frankmiller
Copy link

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.

@Lastique
Copy link
Member

Lastique commented Feb 3, 2023

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.

@Lastique Lastique closed this as completed Feb 3, 2023
@frankmiller
Copy link
Author

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.

@Lastique
Copy link
Member

Lastique commented Feb 3, 2023

Yes, debug build needs fixing.

@Lastique Lastique reopened this Feb 3, 2023
Lastique added a commit that referenced this issue Feb 6, 2023
The previous strategy of force-inlining methods that are dependent
on the library version is not effective with MSVC in debug mode,
when linking the static library. The compiler does not inline
methods despite the markup, and during linking the static library
with the user's module the linker may or may not pick up user's
definitions of these methods.

When building the library, do not define path methods that depend
on the library version. Instead, explicitly call v4 internal methods
throughout the implementation. This way the compiled library does not
contain v4 versions of these methods, and therefore does not conflict
with user's definitions of these methods.

Fixes #279.
Lastique added a commit that referenced this issue Feb 7, 2023
The previous strategy of force-inlining methods that are dependent
on the library version is not effective with MSVC in debug mode,
when linking the static library. The compiler does not inline
methods despite the markup, and during linking the static library
with the user's module the linker may or may not pick up user's
definitions of these methods.

When building the library, do not define path methods that depend
on the library version. Instead, explicitly call v4 internal methods
throughout the implementation. This way the compiled library does not
contain v4 versions of these methods, and therefore does not conflict
with user's definitions of these methods.

Fixes #279.
Lastique added a commit that referenced this issue Feb 7, 2023
The previous strategy of force-inlining methods that are dependent
on the library version is not effective with MSVC in debug mode,
when linking the static library. The compiler does not inline
methods despite the markup, and during linking the static library
with the user's module the linker may or may not pick up user's
definitions of these methods.

When building the library, do not define path methods that depend
on the library version. Instead, explicitly call v4 internal methods
throughout the implementation. This way the compiled library does not
contain v4 versions of these methods, and therefore does not conflict
with user's definitions of these methods.

Fixes #279.
Lastique added a commit that referenced this issue Feb 7, 2023
The previous strategy of force-inlining methods that are dependent
on the library version is not effective with MSVC in debug mode,
when linking the static library. The compiler does not inline
methods despite the markup, and during linking the static library
with the user's module the linker may or may not pick up user's
definitions of these methods.

When building the library, do not define path methods that depend
on the library version. Instead, explicitly call v4 internal methods
throughout the implementation. This way the compiled library does not
contain v4 versions of these methods, and therefore does not conflict
with user's definitions of these methods.

Fixes #279.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants