https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121
--- Comment #23 from Tomasz KamiĆski <tkaminsk at gcc dot gnu.org> --- Part of it seem to be related, by the fact that runtime path does not zero all the elements of the underlying array, i.e. _M_elems[4] in this case. That's prevents `inplace_vector<char, 4>` from being constant expressions (until: P3726R1) Modifying the example to initialize all elements (see https://compiler-explorer.com/z/jYcb3rxzP): #include <inplace_vector> std::inplace_vector<char, 4> f() { return {'a', 'b', 'c', 'd'}; } std::inplace_vector<char, 4> g() { constexpr std::inplace_vector<char, 4> result{'a', 'b', 'c', 'd'}; return result; } Gives for GCC: "f()": lea rax, [rsp-10] mov DWORD PTR [rsp-10], 0 mov BYTE PTR [rsp-6], 0 mov eax, DWORD PTR "C.0.0"[rip] bts rax, 34 ret "g()": movabs rax, 18864104033 ret "C.0.0": .byte 97 .byte 98 .byte 99 .byte 100 And clang: f(): mov byte ptr [rsp - 12], 0 lea rax, [rsp - 16] mov qword ptr [rsp - 8], rax mov dword ptr [rsp - 16], 1684234849 mov byte ptr [rsp - 12], 4 movabs rax, 18864104033 ret g(): movabs rax, 18864104033 ret
