public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/110323] [11/12/13/14 Regression] Code for explicit instantiation of template method of template class not generated
Date: Fri, 08 Mar 2024 17:43:09 +0000 [thread overview]
Message-ID: <bug-110323-4-lcO8G5m8bc@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110323-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110323
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #7)
> I noticed we emit the function if we turn it into a non-member:
>
> #include <type_traits>
>
> constexpr int VAL = 1;
>
> template <int B>
> void bar(typename std::conditional<B==VAL, int, float>::type arg) {
> }
>
> template void bar<1>(int arg);
>
> I wonder why this bug seems specific to member functions?
Good question. It's because in this case bar is marked as force_output here:
/* When not optimizing, also output the static functions. (see
PR24561), but don't do so for always_inline functions, functions
declared inline and nested functions. These were optimized out
in the original implementation and it is unclear whether we want
to change the behavior here. */
if (((!opt_for_fn (decl, optimize) || flag_keep_static_functions
|| node->no_reorder)
&& !node->cpp_implicit_alias
&& !DECL_DISREGARD_INLINE_LIMITS (decl)
&& !DECL_DECLARED_INLINE_P (decl)
&& !(DECL_CONTEXT (decl)
&& TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL))
&& !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
node->force_output = 1;
and when deciding if we ought to emit the fn in symtab_node::needed_p we do:
/* If the user told us it is used, then it must be so. */
if (force_output)
return true;
With -O the fn isn't emitted.
next prev parent reply other threads:[~2024-03-08 17:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 15:57 [Bug c++/110323] New: Code for explicit instantiation of template method of template class stlim0727 at gmail dot com
2023-06-20 16:12 ` [Bug c++/110323] [11/12/13/14 Regression] Code for explicit instantiation of template method of template class not generated pinskia at gcc dot gnu.org
2024-03-05 20:47 ` mpolacek at gcc dot gnu.org
2024-03-05 20:49 ` mpolacek at gcc dot gnu.org
2024-03-05 21:39 ` mpolacek at gcc dot gnu.org
2024-03-05 22:56 ` mpolacek at gcc dot gnu.org
2024-03-06 14:53 ` mpolacek at gcc dot gnu.org
2024-03-07 15:23 ` mpolacek at gcc dot gnu.org
2024-03-08 17:25 ` ppalka at gcc dot gnu.org
2024-03-08 17:43 ` mpolacek at gcc dot gnu.org [this message]
2024-03-08 17:47 ` mpolacek at gcc dot gnu.org
2024-03-21 17:54 ` cvs-commit at gcc dot gnu.org
2024-03-21 17:55 ` [Bug c++/110323] [11/12/13 " mpolacek at gcc dot gnu.org
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-110323-4-lcO8G5m8bc@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: link
Be 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).