default_init results in a memset with GCC16
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start with the small_vector constructor using boost::container::default_init and reproduce the assembly shown with GCC16.0.1, GCC15.2, and Clang 22.1 under -std=c++26 -O3. Compare the generated code and trace whether the memset comes from the container implementation or the compiler; done means identifying the cause and documenting a fix, workaround, or confirmed compiler issue.
Written by the indexing model from the issue text.
Description
It's perhaps a little early to open an issue for this but since I'm already toying with GCC16, I was surprised to see that it now generates a memset to zero init even when default_init is used.
boost::container::small_vector<float, 100> bar(100, boost::container::default_init);
for(auto b : bar)
std::cout << b;
GCC16.0.1 (-std=c++26 -O3):
push r12
mov edx, 424
xor esi, esi
push rbp
push rbx
sub rsp, 432
mov rdi, rsp
lea r12, [rsp+24]
lea rbp, [rsp+424]
call "memset" ; zero init 400 bytes
mov eax, 100
mov QWORD PTR [rsp], r12
mov rbx, r12
movq xmm0, rax
punpcklqdq xmm0, xmm0
movups XMMWORD PTR [rsp+8], xmm0
32-bit (only the relevant bit):
lea eax, [ebp-440]
push 412 ; count
push 0 ; ch
push eax ; dest
call "memset"
GCC15.2 (-std=c++26 -O3):
push r12
mov eax, 100
push rbp
movq xmm0, rax
push rbx
punpcklqdq xmm0, xmm0
sub rsp, 432
lea r12, [rsp+24]
movups XMMWORD PTR [rsp+8], xmm0
lea rbp, [rsp+424]
mov QWORD PTR [rsp], r12
mov rbx, r12
Clang 22.1 (-std=c++26 -O3):
push r15
push r14
push rbx
sub rsp, 432
lea r14, [rsp + 32]
mov qword ptr [rsp + 24], 100
mov qword ptr [rsp + 8], r14
mov qword ptr [rsp + 16], 100
mov r15d, 24
mov rbx, qword ptr [rip + std::cout@GOTPCREL]
I'm not yet sure if this is a compiler regression, an issue with the containers, a skill issue or something else. Again, happy to close it if it's too soon. :)
- Dominant language
- C++
- Stars
- 127
- Forks
- 126
- Avg merge
- 18h 53m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/container
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in boostorg/container
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100