[Bug c++/123577] C++17: Unhelpful constexpr error message when array size exceeds 16 bytes

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 13 17:33:31 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123577

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2026-01-13
     Ever confirmed|0                           |1

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The fix for the code is simple though:
std::array<std::byte, N> ret{};

That is value initialize ret.

In C++17, uniniitialized variables are supposed to be rejected so this is
accepts invalid for <=16 too.  

C++20 allows uninitialized variables to begin with as long as they are fully
initialized at the end of the full constexpr expression.


More information about the Gcc-bugs mailing list