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

Add BOOST_SYSTEM_CURRENT_LOCATION_PTR #84

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

ecatmur
Copy link
Contributor

@ecatmur ecatmur commented Jul 14, 2022

Allows passing current location to error_code ctor without requiring a separate static local variable.

Implementation uses __builtin_source_location() on clang and gcc returning a pointer to std::source_location::__impl, which we verify is layout-compatible with boost::source_location.

ecatmur and others added 8 commits July 14, 2022 18:23
Allows passing current location to error_code ctor without requiring a separate static local variable.

Implementation uses __builtin_source_location() on clang and gcc returning a pointer to std::source_location::__impl, which we verify is layout-compatible with boost::source_location.
the compiler gets confused whether __builtin_FUNCTION() (and the string it points to) is a compile-time constant, and fails or ICEs. Skip this for now.
don't rely on string folding
@ecatmur ecatmur marked this pull request as ready for review July 17, 2022 17:00
@pdimov
Copy link
Member

pdimov commented Feb 3, 2024

I'm looking at this and wondering where we want to go with it.

Ideally, I'd like to make this macro the default argument of the source_location const* parameter everywhere. Not sure when, though.

Looking at the codegen, the first lambda path, the one passing the current location as an argument to the lambda, generates a guard variable. I don't see a way to avoid that, and for me, this kind of rules it out from being silently applied by default.

I suppose we could just use the other one, clearing the function name.

The Clang path seems a bit dubious; while clang-cl supports __builtin_source_location(), it doesn't work, because in the MS STL, std::source_location doesn't have an __impl member.

Also, Clang using libstdc++ would use its std::source_location, which would make __impl inaccessible, but the test doesn't seem to account for this, it only looks at the compiler.

If we consider the _PTR macro an implementation detail that's only used as a default argument, I think we can dispense with the type safety and just use an ordinary pointer.

@pdimov
Copy link
Member

pdimov commented Feb 4, 2024

I don't see a way to avoid that

Maybe we could just do a little data race: https://godbolt.org/z/fq6ETGqcP

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

Successfully merging this pull request may close these issues.

2 participants