[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 --- Comment #6 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:a426b91b27e28985f47d16827a532fbc28c09bd7 commit r14-2820-ga426b91b27e28985f47d16827a532fbc28c09bd7 Author: Patrick Palka Date: Thu Jul 27 09:10:07 2023 -0400 c++: constexpr empty subobject elision [PR110197] Now that init_subob_ctx no longer sets new_ctx.ctor for a subobject of empty type, it seems we need to ensure its callers also consistently omit entries in the parent ctx->ctor for such subobjects. We also need to allow cxx_eval_array_reference to synthesize an empty subobject even if the array CONSTRUCTOR has CONSTRUCTOR_NO_CLEARING set. PR c++/110197 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_array_reference): Allow synthesizing an empty subobject even if CONSTRUCTOR_NO_CLEARING is set. (cxx_eval_bare_aggregate): Set 'no_slot' to true more generally whenever new_ctx.ctor is set to NULL_TREE by init_subob_ctx, i.e. whenever initializing an subobject of empty type. (cxx_eval_vec_init_1): Define 'no_slot' as above and use it accordingly. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-empty18.C: New test. * g++.dg/cpp0x/constexpr-empty19.C: New test.
[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 Richard Biener changed: What|Removed |Added Target Milestone|13.2|13.3 --- Comment #5 from Richard Biener --- GCC 13.2 is being released, retargeting bugs to GCC 13.3.
[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 --- Comment #4 from Patrick Palka --- Looks like this issue isn't specific to constexpr array construction: struct Currency { constexpr Currency(int) { } }; constexpr int f() { return __builtin_is_constant_evaluated(); }; struct A { Currency _M_elems; }; constexpr A _M_elems = {Currency{f()}}; Since r13-963 we reject this with :8:38: error: ‘A{(void)0}’ is not a constant expression
[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 Patrick Palka changed: What|Removed |Added CC||ppalka at gcc dot gnu.org --- Comment #3 from Patrick Palka --- More reduced: struct Currency { constexpr Currency(int) { } }; constexpr int f() { return __builtin_is_constant_evaluated(); }; constexpr Currency _M_elems[1] = {Currency{f()}};
[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 --- Comment #2 from Marek Polacek --- // PR c++/110197 namespace std { constexpr bool __is_constant_evaluated() { return __builtin_is_constant_evaluated(); } template using enable_if_t = _Tp; template struct __array_traits { typedef _Tp _Type[_Nm]; }; template struct array { typename __array_traits<_Tp, _Nm>::_Type _M_elems; }; template array(_Tp) -> array, 1>; struct char_traits { static constexpr unsigned length() { __is_constant_evaluated(); return 0; } }; struct basic_string_view { using traits_type = char_traits; constexpr basic_string_view(const char *) : _M_len{traits_type::length()}, _M_str{} {} long _M_len; char _M_str; }; } // namespace std struct Currency { constexpr Currency(std::basic_string_view) {} }; void get_c() { constexpr std::array c{Currency{""}}; }
[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 Marek Polacek changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #1 from Marek Polacek --- Started with r13-963: commit d19b4342c19e5a7fd84888aa06ebc106438d0c46 Author: Jason Merrill Date: Wed Jun 1 17:30:25 2022 -0400 c++: more constexpr empty base [PR105795] Following on from the previous patch, for trunk let's consistently set ctx->ctor to NULL_TREE for empty subobjects.
[Bug c++/110197] [13/14 Regression] Empty constexpr object constructor erronously claims out of range access
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110197 Marek Polacek changed: What|Removed |Added Priority|P3 |P2 Status|UNCONFIRMED |NEW Last reconfirmed||2023-06-09 Ever confirmed|0 |1 Target Milestone|--- |13.2 Keywords||rejects-valid CC||mpolacek at gcc dot gnu.org Summary|Empty constexpr object |[13/14 Regression] Empty |constructor erronously |constexpr object |claims out of range access |constructor erronously ||claims out of range access