Path: utzoo!mnetor!uunet!sdrc!scjones From: scjones@sdrc.UUCP (Larry Jones) Newsgroups: comp.lang.c Subject: Re: Bit Addressable Architectures Message-ID: <259@sdrc.UUCP> Date: 14 Apr 88 22:05:21 GMT References: <11702@brl-adm.ARPA> <243@eagle_snax.UUCP> <2245@geac.UUCP> <7684@brl-smoke.ARPA> Organization: Structural Dynamics Research Corp., Cincinnati Lines: 26 In article <7684@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <8646@eleazar.Dartmouth.EDU> major@eleazar.Dartmouth.EDU (Lou Major) writes: > >char foo[]="This is a test."; > >sizeof (foo) == sizeof (char *) > > Since when? > > I know that Gould had a bug in their UTX-32 compiler that made it think > sizeof"......"==sizeof(char *), but they fixed that and in any case > it's not the same as your example. So what gives? > > (I don't think the array name is turned into a pointer just because it's > surrounded by parentheses.) If it ain't, the compiler's broke! The sizeof operator can be applied to a parenthesized type name or to an expression. Since "foo" isn't a type name, the operand of sizeof is an expression. When an array name appears in an expression and it's not the operand of & or sizeof (whose operand is the parenthesized express, remember), it's converted into a pointer to the first element. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC MAIL: 2000 Eastman Dr., Milford, OH 45150 AT&T: (513) 576-2070 "When all else fails, read the directions."