https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101651
Bug ID: 101651 Summary: constexpr write to simd vector element Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- (adapted from https://stackoverflow.com/q/68517921/1918193) #ifdef WORK #include <array> typedef std::array<char,16> vec; #else typedef char vec __attribute__((vector_size(16))); #endif constexpr auto gen () { vec ret{}; for (int i = 0; i < sizeof(vec); ++i) { ret[i] = 2; } return ret; }; constexpr auto m = gen(); c.cc:9:23: in 'constexpr' expansion of 'gen()' c.cc:9:24: error: modification of '(char [16])ret' is not a constant expression 9 | constexpr auto m = gen(); | ^ However, with -DWORK to use std::array instead of the vector extension, it compiles just fine, so there shouldn't be any strong obstacle to implement this.