public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102363] New: source_location in await_transform has function_name referring to internal coroutine funclet rather than source-level function
@ 2021-09-16 11:15 redbeard0531 at gmail dot com
2021-09-30 15:38 ` [Bug c++/102363] " iains at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: redbeard0531 at gmail dot com @ 2021-09-16 11:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102363
Bug ID: 102363
Summary: source_location in await_transform has function_name
referring to internal coroutine funclet rather than
source-level function
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redbeard0531 at gmail dot com
Target Milestone: ---
When a promise_type::await_transform() has a defaulted argument of
source_location::current(), it refers to the location of the co_await that
triggered the await_transform. This is really useful for building runtime
diagnostics and tracing. The file/line/column fields all seem to be filled out
correctly, however, the function_name field refers to an internal funclet that
the coroutine function is split into. I think it would be more useful if it had
the original corountine function name since that is what users will be
expecting.
Example: https://godbolt.org/z/sbMsPG8Eq
Output:
good: /app/example.cpp:20:43: example func()
bad: /app/example.cpp:25:14: void func(func()::_Z4funcv.frame*)
Source (compiled with just -std=c++20):
#include <coroutine>
#include <source_location>
#include <cstdio>
struct example {
struct promise_type {
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() { throw; }
example get_return_object() { return {}; }
void return_void() {}
auto await_transform(const char* dummy, std::source_location l =
std::source_location::current()) {
printf("bad: %s:%u:%u: %s\n", l.file_name(), l.line(), l.column(),
l.function_name());
return std::suspend_never();
}
};
};
example func() {
auto l = std::source_location::current();
printf("good: %s:%u:%u: %s\n", l.file_name(), l.line(), l.column(),
l.function_name());
// bad location points here:
// v
co_await "pretend this is an awaitable";
}
int main() {
func();
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/102363] source_location in await_transform has function_name referring to internal coroutine funclet rather than source-level function
2021-09-16 11:15 [Bug c++/102363] New: source_location in await_transform has function_name referring to internal coroutine funclet rather than source-level function redbeard0531 at gmail dot com
@ 2021-09-30 15:38 ` iains at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: iains at gcc dot gnu.org @ 2021-09-30 15:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102363
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-09-30
Status|UNCONFIRMED |NEW
CC| |iains at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
source location information needs some work in the synthesis - the defaults are
not the most useful.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-30 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 11:15 [Bug c++/102363] New: source_location in await_transform has function_name referring to internal coroutine funclet rather than source-level function redbeard0531 at gmail dot com
2021-09-30 15:38 ` [Bug c++/102363] " iains at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).