Integer Literals in code are constants like 10, 20, -100, etc
The analyser in c2c currently distinguishes between 3 types of expressions:
fully compile-time-constant: basically any number
partial compile-time-contant: a + 10
not compile time constant: a, calc()
Full:
char a = 128; -> error 128 not in range of char, range [0, 127]
char b = 800 - 700; // ok, since 100 is in range
So the entire expression is evaluated and checked against the range.
None:
char a = b; // error if type of b is larger than char.
So just the types are checked
Partial: (this is where it starts to get fuzzy)
char a = 128 + b; // (b = char) so should this be allowed?
or the previous example:
char b = 800 - 700 + a; // char a, should this be allowed?
Here there are some choices I think:
1 don't check any ranges of partial ctc expressions
2 only allow subexpressions to be of same < smaller type/value
3 check if range could be ok(Clang has a crude implementation of this)
I would prefer option 2, since it is the most safe option, but it would
restrict programmers too much perhaps. I think this would be ok,
but what do you guys think?
Bas