public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bobk-off at yandex dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113809] New: Error of constexpr variable creation due to combined use of std::tuple, copy constructor and static function Date: Wed, 07 Feb 2024 13:57:16 +0000 [thread overview] Message-ID: <bug-113809-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113809 Bug ID: 113809 Summary: Error of constexpr variable creation due to combined use of std::tuple, copy constructor and static function Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bobk-off at yandex dot ru Target Milestone: --- Compiler reports following error on code below: in 'constexpr' expansion of 'A<int>(MakeFullPGNsMap::value)' in 'constexpr' expansion of '((A<int>*)this)->A<int>::A<0>(other.A<int>::mTuple, (std::make_index_sequence<1>(), std::make_index_sequence<1>()))' error: the value of 'MakeFullPGNsMap::value' is not usable in a constant expression Note: code is strognly reduced to only demonstrate compilation error. Code: #include <algorithm> #include <tuple> template<typename T, typename ... TARGS> struct ConstantObject { static constexpr T value = { TARGS::value... }; }; template<typename ... Ts> struct A { A & operator =(const A & other) = delete; constexpr A(const std::tuple<Ts...> & tuple) : A(tuple, std::make_index_sequence<sizeof...(Ts)>()) {} constexpr A(const A & other) : A(other.mTuple, std::make_index_sequence<sizeof...(Ts)>()) {} private: template<size_t ... Is> constexpr A(const std::tuple<Ts...> & tuple, std::index_sequence<Is...>) : mTuple(tuple), mMap{ &std::get<Is>(mTuple)... } {} std::tuple<Ts...> mTuple; const void * mMap[sizeof...(Ts)] = {}; }; template<typename ... Ts> static constexpr A<Ts...> make_a(const std::tuple<Ts...> & spns) { return A<Ts...>(spns); } struct MakeFullPGNsMap {; static constexpr A<int> value = make_a(std::make_tuple(5)); }; using X = ConstantObject<decltype(MakeFullPGNsMap::value), MakeFullPGNsMap>; const void * y; int main() { y = &X::value; return 0; }
next reply other threads:[~2024-02-07 13:57 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-07 13:57 bobk-off at yandex dot ru [this message] 2024-02-08 12:52 ` [Bug c++/113809] " redi 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-113809-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).