🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3693

'sizeof e' vs. 'sizeof (T)' (was: Re: Parenthesis with return ?)

#3693
From: scott douglass
Date: Thu, 10 Aug 1995 10:04
19 lines
1309 bytes
In article <6495221.12652.4448@kcbbs.gen.nz>, martin@kcbbs.gen.nz (Martin
Kealey) wrote:

> The shift states in many parsers would see that as a cast leading into an
> expression, and then note that the thing following the ) is not valid for an
> expression, and reduce the sizeof.

This last explaination can be misleading.  'sizeof' can be followed by a
"unary-expression" not something more general like "expression". Otherwise
the following would be ambigous: 

      sizeof (char) + 1
            this is '(sizeof(char)) + 1', i.e. '2'; not 'sizeof
((char)+1)', i.e. '1'
            [wow, I actually found a "use" for unary '+'!]

      char c; sizeof c + 1
            this is '(sizeof c) + 1', i.e. '2'; not 'sizeof (c + 1)', i.e. '1'
       --scott
Technical Details
Message-ID: <sdouglass-1008951104490001@193.131.176.202>
Path: arc1-ca.pugleaf.net!armltd.co.uk!NewsWatcher!user
References: <405fhs$iin@boson.epita.fr> <DCy9uG.CEr@proteon.com> <DCz7qw.HvM@stdc.demon.co.uk> <6495221.12652.4448@kcbbs.gen.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!armltd.co.uk!NewsWatcher!user
From: sdouglass@armltd.co.uk (scott douglass)
Newsgroups: comp.std.c
Subject: 'sizeof e' vs. 'sizeof (T)' (was: Re: Parenthesis with return ?)
Date: Thu, 10 Aug 1995 11:04:49 +0100
Organization: Apple Computer, Inc.
Message-ID: <sdouglass-1008951104490001@193.131.176.202>
References: <405fhs$iin@boson.epita.fr> <DCy9uG.CEr@proteon.com> <DCz7qw.HvM@stdc.demon.co.uk> <6495221.12652.4448@kcbbs.gen.nz>
NNTP-Posting-Host: 193.131.176.202
X-Newsreader: Value-Added NewsWatcher 2.0b27.1+