Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!nike!ll-xn!mit-amt!mit-eddie!genrad!decvax!ittatc!bunker!garys From: garys@bunker.UUCP (Gary M. Samuelson) Newsgroups: net.lang.c Subject: Re: sizeof (int) - 1 Message-ID: <1217@bunker.UUCP> Date: Wed, 1-Oct-86 14:25:58 EDT Article-I.D.: bunker.1217 Posted: Wed Oct 1 14:25:58 1986 Date-Received: Sat, 4-Oct-86 02:08:20 EDT References: <102500008@uiucuxc> <271@hoqam.UUCP> Reply-To: garys@bunker.UUCP (Gary M. Samuelson) Organization: Bunker Ramo, Trumbull Ct Lines: 23 >> It is interesting that the expression >> sizeof (int) - 1 >> is ambiguous in C, for it can be parsed as >> sizeof ((int)(- 1)) >> or as >> (sizeof(int)) - 1 >> The unix compiler does it the second way, for when it sees the '-' it ------------- (speaking of ambiguous) >> sets the precedence for that character ASSUMING it will be used as a >> binary operator. >There is nothing ambiguous about it. >K&R p188: >"The construction sizeof(type) is taken to be a unit, so the >expression sizeof(type)-2 is the same as (sizeof(type))-2." You're both partially right, and partially wrong. The expression would be ambiguous, if not for the disambiguating rule where the compiler is not *assuming* that the minus sign is binary, but *deciding* that it is. Gary Samuelson