int とlong long のビット演算でハマった話

#include <iostream>
#include <bitset>
using namespace std;
using ll = long long;

int main() {
    ll a = 0, b = 0, c = 0;
    for(int i=0; i<32; ++i) {
        a |= (1 << i);
    }
    for(int i=0; i<32; ++i) {
        b |= (1ll << i);
    }
    c |= (1 << 31);
    cout << bitset<64>(a) << endl;
    cout << bitset<64>(b) << endl;
    cout << bitset<64>(c) << endl;
}

Output:

1111111111111111111111111111111111111111111111111111111111111111
0000000000000000000000000000000011111111111111111111111111111111
1111111111111111111111111111111110000000000000000000000000000000

つらい.ちゃんと確認しような.