[PR #16742] Fix an apparent x86 miscompilation on MSVC 19.38 #30983

Open
opened 2026-01-31 09:44:20 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/16742

State: closed
Merged: Yes


There's an apparent miscompilation of dynamic_bitset on x86 with
MSVC 19.38, where the following code:

dynamic_bitset<uint64_t> bits(80 * 24, 0);
bits.set(0, 3 * 80, true);

is expected to set the first 3.75 blocks to 1 which should produce
the following blocks:

0xffffffffffffffff
0xffffffffffffffff
0xffffffffffffffff
0x0000ffffffffffff

but it actually produces:

0xffffffffffffffff
0x00000000ffffffff
0xffffffffffffffff
0x0000ffffffffffff

The weird thing here is that this only happens if til::bitmap
uses a dynamic_bitset<uint64_t>. As soon as it uses <uint32_t>
any other instantiation of <uint64_t> is magically fixed.

Conclusion: Use size_t until we know what's going on.
Last known good CL version: 14.37.32822
Current broken CL version: 14.38.33130

Validation Steps Performed

The following test completes successfully again:

til::bitmap map{ { 80, 24 } };
map.translate({ 0, 3 }, true);
VERIFY_ARE_EQUAL(3u, map.runs().size());
**Original Pull Request:** https://github.com/microsoft/terminal/pull/16742 **State:** closed **Merged:** Yes --- There's an apparent miscompilation of `dynamic_bitset` on x86 with MSVC 19.38, where the following code: ```cpp dynamic_bitset<uint64_t> bits(80 * 24, 0); bits.set(0, 3 * 80, true); ``` is expected to set the first 3.75 blocks to 1 which should produce the following blocks: ``` 0xffffffffffffffff 0xffffffffffffffff 0xffffffffffffffff 0x0000ffffffffffff ``` but it actually produces: ``` 0xffffffffffffffff 0x00000000ffffffff 0xffffffffffffffff 0x0000ffffffffffff ``` The weird thing here is that this only happens if `til::bitmap` uses a `dynamic_bitset<uint64_t>`. As soon as it uses `<uint32_t>` any other instantiation of `<uint64_t>` is magically fixed. Conclusion: Use `size_t` until we know what's going on. Last known good CL version: 14.37.32822 Current broken CL version: 14.38.33130 ## Validation Steps Performed The following test completes successfully again: ```cpp til::bitmap map{ { 80, 24 } }; map.translate({ 0, 3 }, true); VERIFY_ARE_EQUAL(3u, map.runs().size()); ```
claunia added the pull-request label 2026-01-31 09:44:20 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30983