public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113809] New: Error of constexpr variable creation due to combined use of std::tuple, copy constructor and static function
@ 2024-02-07 13:57 bobk-off at yandex dot ru
2024-02-08 12:52 ` [Bug c++/113809] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: bobk-off at yandex dot ru @ 2024-02-07 13:57 UTC (permalink / raw)
To: gcc-bugs
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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/113809] Error of constexpr variable creation due to combined use of std::tuple, copy constructor and static function
2024-02-07 13:57 [Bug c++/113809] New: Error of constexpr variable creation due to combined use of std::tuple, copy constructor and static function bobk-off at yandex dot ru
@ 2024-02-08 12:52 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-08 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113809
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-02-08
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Clang compiles this even when using libstdc++ headers.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-08 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 13:57 [Bug c++/113809] New: Error of constexpr variable creation due to combined use of std::tuple, copy constructor and static function bobk-off at yandex dot ru
2024-02-08 12:52 ` [Bug c++/113809] " redi at gcc dot gnu.org
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).