public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107939] [11/12 Regression] Rejects use of `extern const` variable in a template since r11-557 Date: Tue, 07 Mar 2023 15:25:05 +0000 [thread overview] Message-ID: <bug-107939-4-e6natu6dOz@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107939-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107939 --- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:19ed6bf44c3fec882cf4c825f3ffa4f2ecdc78e6 commit r12-9232-g19ed6bf44c3fec882cf4c825f3ffa4f2ecdc78e6 Author: Marek Polacek <polacek@redhat.com> Date: Fri Mar 3 11:24:24 2023 -0500 c++: error with constexpr operator() [PR107939] Similarly to PR107938, this also started with r11-557, whereby cp_finish_decl can call check_initializer even in a template for a constexpr initializer. Here we are rejecting extern const Q q; template<int> constexpr auto p = q(0); even though q has a constexpr operator(). It's deemed non-const by decl_maybe_constant_var_p because even though 'q' is const it is not of integral/enum type. If fun is not a function pointer, we don't know if we're using it as an lvalue or rvalue, so with this patch we pass 'any' for want_rval. With that, p_c_e/VAR_DECL doesn't flat out reject the underlying VAR_DECL. PR c++/107939 gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1) <case CALL_EXPR>: Pass 'any' when recursing on a VAR_DECL and not a pointer to function. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ74.C: Remove dg-error. * g++.dg/cpp1y/var-templ77.C: New test. (cherry picked from commit e09bc034d1b4d692b409fa5af52ae34480a6f4dc)
next prev parent reply other threads:[~2023-03-07 15:25 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-30 19:32 [Bug c++/107939] New: Rejects use of `extern const` variable in a template johelegp at gmail dot com 2022-11-30 19:35 ` [Bug c++/107939] [11/12/13 Regression] " pinskia at gcc dot gnu.org 2022-11-30 19:36 ` johelegp at gmail dot com 2022-12-01 8:04 ` rguenth at gcc dot gnu.org 2022-12-02 14:19 ` [Bug c++/107939] [11/12/13 Regression] Rejects use of `extern const` variable in a template since r11-557 jakub at gcc dot gnu.org 2023-03-02 22:48 ` mpolacek at gcc dot gnu.org 2023-03-03 0:02 ` mpolacek at gcc dot gnu.org 2023-03-03 16:35 ` mpolacek at gcc dot gnu.org 2023-03-07 15:13 ` cvs-commit at gcc dot gnu.org 2023-03-07 15:16 ` [Bug c++/107939] [11/12 " mpolacek at gcc dot gnu.org 2023-03-07 15:25 ` cvs-commit at gcc dot gnu.org [this message] 2023-03-07 15:25 ` [Bug c++/107939] [11 " mpolacek at gcc dot gnu.org 2023-11-16 14:32 ` cvs-commit at gcc dot gnu.org 2023-11-24 16:56 ` cvs-commit at gcc dot gnu.org 2023-11-27 22:02 ` cvs-commit 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-107939-4-e6natu6dOz@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).