public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kentsangkm at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106619] New: Inconsistent __PRETTY_FUNCTION__ output Date: Mon, 15 Aug 2022 08:05:37 +0000 [thread overview] Message-ID: <bug-106619-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106619 Bug ID: 106619 Summary: Inconsistent __PRETTY_FUNCTION__ output Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kentsangkm at gmail dot com Target Milestone: --- Created attachment 53456 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53456&action=edit example code The __PRETTY_FUNCTION__ macro does print the function name as well as the template arguments (if any), but the output is inconsistent and depends on the declaration sequence. // any templated typed with optional parameter(s) template<typename T, typename U = std::conditional_t<std::is_void_v<T>, void, T>> struct Foo { }; template<typename T> struct Container { void get() const{ std::cout << typeid(T).name() << " "<< __PRETTY_FUNCTION__ << std::endl; } }; int main() { Container<Foo<int, int>> b; b.get(); Container<Foo<int>> a; a.get(); } Output: 3FooIiiE void Container<T>::get() const [with T = Foo<int, int>] 3FooIiiE void Container<T>::get() const [with T = Foo<int, int>] If we swap the declaration of a and b, the output becomes: 3FooIiiE void Container<T>::get() const [with T = Foo<int>] 3FooIiiE void Container<T>::get() const [with T = Foo<int>] in contrast, the typeid is very consistent on both cases, but it is not an constexpr function Clang does not have such issue, as it always expends the optional arguments and output Foo<int, int> always Here is a short link for godbolt https://godbolt.org/z/vfTnz5bEb the same code piece is also be enclosed
reply other threads:[~2022-08-15 8:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-106619-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).