Re: sizeof(type)

Mouse <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
>> 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		[email protected]
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.