🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3724

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

#3724
From: Paul Long
Date: Mon, 14 Aug 1995 15:36
24 lines
1477 bytes
clive@stdc.demon.co.uk (Clive D.W. Feather) wrote:
>
>In article <3415076830.8283127@ortel.org>,
>Paul Long <Paul_Long@ortel.org> wrote:
>> If [...] the following would all yield 1:
>>   sizeof(char)
>>   sizeof(int)
>>   sizeof c
>>   sizeof c + 1
>
>The last of these can never be 1 (assuming it occurs in a strictly
>conforming program).

Sure it would.  The usual arithmetic promotions would cause "c" to be 
converted to int as part of the integral promotions. At that point, both 
sides would be type, int, and the type of the expression would therefore 
also be type int. If an int is 16 bits long and a "byte," as defined by 
the Standard, is 16 bits long (CHAR_BIT is 16), "sizeof c + 1" would 
yield 1 because it has the value of the number of bytes in the type of 
the expression, which in this case would be 1 "byte." Why do you think 
"sizeof c + 1" can never be 1 in a conforming program?

Paul Long
(responding via his Prodigy account because he's on the road)
Technical Details
Message-ID: <40nqhd$1rs4@usenetp1.news.prodigy.com>
Path: arc1-ca.pugleaf.net!prodigy.com!usenet
References: <3415076830.8283127@ortel.org> <dd9uho.ajm@stdc.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!prodigy.com!usenet
From: NGMV85A@prodigy.com (Paul Long)
Newsgroups: comp.std.c
Subject: Re: 'sizeof e' vs. 'sizeof (T)' (was: Re: Parenthesis with return ?)
Date: 14 Aug 1995 15:36:13 GMT
Organization: Prodigy Services Company  1-800-PRODIGY
Distribution: world
Message-ID: <40nqhd$1rs4@usenetp1.news.prodigy.com>
References: <3415076830.8283127@ortel.org> <dd9uho.ajm@stdc.demon.co.uk>
NNTP-Posting-Host: inugap3.news.prodigy.com
X-Newsreader: Version 1.2