Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: sizeof() confusion Message-ID: <14501@smoke.brl.mil> Date: 17 Nov 90 13:52:12 GMT References: <1990Nov14.154213.27324@cbnewsj.att.com> <14462@smoke.brl.mil> <1990Nov16.141352.22426@dce.ie> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 20 In article <1990Nov16.141352.22426@dce.ie> ch@dce.ie (Charles Bryant) writes: >> there are two distinct uses of sizeof: >> sizeof unary_expression >> sizeof ( type_name ) >That must make parsing it more difficult than if the parentheses were always >required ... Yes, but this is necessary since C has "always" (actually, just for a long time) had those two distinct usages of "sizeof". Note that most published precedence tables for C operators, including K&R's, get this wrong. Using an example similar to the one you gave: sizeof ( short ) - 1 K&R's chart (p. 49 or 53, depending on edition) would have one parse this as sizeof ((short) (- 1)) whereas the only valid parse according to the C standard (and all existing compilers of which I am aware) is (sizeof (short)) - 1 which has a different value.