C has plenty of ambiguity:
I see no ambiguity here. Things that may not match what you want, yes.
If you hate C so much, why do you still use it?
- Braces are optional if there is only one statement for if() or for() or
while(). (But not for do ... while(), switch, or structure/union
declarations.)
There is always precisely one statement controlled by if, for, while, or
do..while (and even switch, though it's rather useless there). That one
statement may be a simple expression statement or a compound statement;
compound statements (by definition) begin with a '{' and end with a '}'.
struct and union declarations don't involve any statements, so your
claim is meaningless when applied to that.
- If a statement has multiple side effects, the order in which those side
effects take place can be unknown.
If a statement has multiple side effects whose order is relevant,
it shouldn't've been written as a single statement in the first place.
If the only purpose of defining something is so that you can look at the
language definition to find out what bad code is really doing, it's not
worth defining.
- The right shift operator may or may not sign extend signed integers. Its
implementation defined.
Is there any reason why it should be defined in some particular way?
If you want sign extension of signed integers, use the division operator;
any self-respecting compiler will use a shift instruction for that where
it's appropriate. If you want to move the bits around without worrying
about sign bits, use unsigned integers and avoid the sign bit entirely.
- The size of an integer is platforms specific.
So? Do you care if the machine gives you 16 more bits than you need?
- The number of bits in a bytes is platform specific.
So? Do you care if the system gives you 2 more bits than you need?
- Try this one on for size:
char a = -1, b = -2;
unsigned short x = (1 > 0) ? a : b;
printf ("x = %d\n", x);
What do you think is printed out? Explain it.
A number that, if you think about it hard enough, will give you some clue
about whether char is signed and possibly about how signed integers are
represented internally.
You're lying to printf; what did you expect, a compiler error saying
"That's not what you meant"?
dave