// Tests: invalid shift counts and left-shift causing UB
// Clause: 6.5.8 p3–p4 — if right operand is negative or >= width of promoted left operand, behavior is undefined.
// Clause: 6.5.8 p4 — for signed left shift where result is not representable, behavior is undefined.
#include <limits.h>
#include <stdio.h>

int main(void) {
    int neg = -1;
    int x1 = 1 << neg; // UB: negative shift count (6.5.8 p3)
    (void)x1;

    int w = (int)(sizeof(int)*CHAR_BIT);
    int x2 = 1 << w;   // UB: shift count == width (>= width) (6.5.8 p3)
    (void)x2;

    int x3 = INT_MAX;
    x3 = x3 << 1;      // UB on 2's complement if not representable (6.5.8 p4)
    printf("%d\n", x3);
    return 0;
}
