https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115399
Bug ID: 115399 Summary: std::tr2::dynamic_bitset shift behaves differently from std::bitset Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: adamant.pwn at gmail dot com Target Milestone: --- Target: x86-64 Linux Build: 20240522 Posting a bug on behalf of someone who didn't manage to create an account at GCC bugzilla due to automatic registration being disabled... The bug is due to the line https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/tr2/dynamic_bitset.tcc#L63 being commented out in dynamic_bitset implementation (unlike std::bitset, where it is present). Uncommenting it should fix the problem. A simple example program to highlight the discrepancy: #include <iostream> #include <bitset> #include <tr2/dynamic_bitset> int main() { std::tr2::dynamic_bitset<> test(91); test[50] = true; std::cout << test << "\n"; std::cout << (test << 78) << "\n"; std::cout << "\n"; std::bitset<91> test2; test2[50] = true; std::cout << test2 << "\n"; std::cout << (test2 << 78) << "\n"; } Output: 0000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000