-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
__func__
(, __PRETTY_FUNCTION__
, __FUNCSIG__
) does not resolve to directly-containing *function-body* when appearing in lambda's trailing return type
#122657
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
lambda
C++11 lambda expressions
Comments
frederick-vs-ja
added
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
lambda
C++11 lambda expressions
and removed
new issue
labels
Jan 13, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
lambda
C++11 lambda expressions
Compiler Explorer, x64-64 clang (trunk), -std=c++26 -O2 -Wall -pedantic -pthread:
Program returned: 0
Program stdout
As shown in above example, a workaround can be to access the correct
__func__
/__PRETTY_FUNCTION__
/__FUNCSIG__
when in lambda's template parameter list.Use scenario (for having the correct value of
__func__
/__PRETTY_FUNCTION__
/__FUNCSIG__
in lambda's trailing return type):__func__
and flushes its content tostd::cout
/std::cerr
on destruction (likeqDebug()
). But unlikeqDebug()
which uses__func__
only for printing and has no knowledge of the following parameters, this stream object also uses expression template to capture all the following parameters, so that when their types (including__func__
's type) are available, it knows how much memory should be allocated in advance (or, when records of same size are grouped together, it knows which bucket to send its output to).std::cout
which outputs ASAP, rvaluestd::osyncstream(std::cout)
/qDebug().noquote().nospace()
which outputs on destruction), expands to a guard object definitioin that stores the stream object and does something before its construction and after its destruction. Thedefinition
/does something
part needs a data_member/variable that is of typeT&
ifstream_expression
is lvalue andT
otherwise, then at some point the use case[](decltype((stream_expression)) s)->???<my::remove_rvalue_reference_t<decltype((stream_expression))>>{...}(stream_expression)
which needs correct__func__
appears.The text was updated successfully, but these errors were encountered: