Skip to content

Instantly share code, notes, and snippets.

@bcantrill
Created November 21, 2011 02:38
Show Gist options
  • Save bcantrill/8aca3200f31a843b589f to your computer and use it in GitHub Desktop.
Save bcantrill/8aca3200f31a843b589f to your computer and use it in GitHub Desktop.
The surprising semantics of integral promotion
#include <stdio.h>
int
main()
{
unsigned char a = 1, b = 2, c = 0;
if (a - b >= c)
printf("Expression true without explicit cast.\n");
if ((unsigned char)(a - b) >= c)
printf("Expression true with explicit cast.\n");
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment