tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sizeof(type)
>> I suspect some ambiguity without the parentheses, but I fail do make
>> up one.
> The expression 'sizeof int * + 1' has two different interpretations:
> sizeof(int) * (+1)
> sizeof(int *) + 1
There's also
sizeof (int) - 1
which is ambiguous even _with_ the parens; it means either
(sizeof(int))-1
or
sizeof((int)-1)
In this case, I think the ambiguity is resolved by operator precedence
(though I'm not certain, since one component - the (int) - shifts
between being an operator and being an operand between the
interpretations). I think operator precedence even less resolves the
"* as pointer vs multiplication" question, so yours is a much better
example of why the parens around types are needed.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index