https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115399

--- Comment #1 from Oleksandr Kulkov <adamant.pwn at gmail dot com> ---
The bug also affects right shift for a similar reason
(https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/tr2/dynamic_bitset.tcc#L91):

#include <iostream>
#include <bitset>
#include <tr2/dynamic_bitset>
#include <boost/dynamic_bitset.hpp>

int main() {
    std::tr2::dynamic_bitset<> test(128);
    for (int i = 64; i < 128; i++) test[i] = 1;
    std::cout << test << "\n";
    std::cout << (test >> 65) << "\n\n";

    boost::dynamic_bitset<> test2(128);
    for (int i = 64; i < 128; i++) test2[i] = 1;
    std::cout << test2 << "\n";
    std::cout << (test2 >> 65) << "\n\n";

    std::bitset<128> test3;
    for (int i = 64; i < 128; i++) test3[i] = 1;
    std::cout << test3 << "\n";
    std::cout << (test3 >> 65) << "\n\n";
}

Output:

11111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000
11111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111

11111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111

11111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111

See also https://github.com/emsr/tr2/issues/1.

Reply via email to