News for hackers. Stuff that matters.
Re:Why Is SQLite Coded in C? (2017) by jstimpfle on Saturday March 17, 2018 @11:27AM (#16607359)
Point taken. I agree that the weakly typed nature of C (integer promotions / implicit casts) can be problematic. Would be interesting to see if there are programs that would be painful to write with a stricter model.

It seems I've never really done "overshifting", otherwise I would have easily noticed that the shifted value is promoted first. If you don't overshift there's no way to trigger the undefined behaviour, even when you shift multiple times - since by assigning to the smaller type the result gets cut down again, effectively leading to the behaviour I'd assumed. I would hardly call this a gotcha.

Where it might be confusing is in a situation like this:

    char x = 42;
    printf("%d\n", x << 4);
But then again I'm undecided if the behaviour is that bad. It might be even useful.

There are no comments on this comment yet.