public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zakeria433 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95968] New: error: 'args#0' is not a constant expression Date: Mon, 29 Jun 2020 15:39:34 +0000 [thread overview] Message-ID: <bug-95968-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95968 Bug ID: 95968 Summary: error: 'args#0' is not a constant expression Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zakeria433 at gmail dot com Target Milestone: --- Hi, command: g++ test_class.cpp -Wall -Wextra -std=c++20 System: Debian 10 The following code is rejected by Gcc 10.1. However, if I replace test_class's constructor with constexpr instead of consteval, it does compile on gcc. // Example program #include <tuple> #include <type_traits> // #include <concepts> template<typename T, typename ... Pack> requires(std::is_floating_point<T>::value) class test_class { public: const T first_param; const std::tuple <Pack...> pack; consteval test_class(T first_param_, Pack... pack_) : first_param(first_param_), pack(pack_...) { } consteval auto test_func() { //auto p = first_param; auto x = std::apply([/*p*/](const auto ... args) {return test_class(1.0, args...);}, pack); return x; } }; int main() { constexpr auto var1 = test_class(4.0); //constexpr auto var2 = test_class(5.0); constexpr auto var3 = test_class(12.0, var1).test_func(); //static_assert(vart3.first_param == 12, "assert fail"); } error: ‘args#0’ is not a constant expression 22 | auto x = std::apply([/*p*/](const auto ... args) {return test_class(1.0, args...);}, pack); | ^~~~~~~~~~~~~~~~~~~~~~~~ Live demo: https://godbolt.org/z/oWWFaP
next reply other threads:[~2020-06-29 15:39 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-29 15:39 zakeria433 at gmail dot com [this message] 2020-07-08 22:45 ` [Bug c++/95968] " mpolacek at gcc dot gnu.org 2021-10-02 6:05 ` pinskia at gcc dot gnu.org 2022-01-17 10:52 ` pinskia at gcc dot gnu.org 2023-01-19 1:26 ` pinskia 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-95968-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).