🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #42749

Re: TC bug in sizeof()?

#42749
From: Stephen M. Dunn
Date: Mon, 26 Feb 1990 19:37
20 lines
1640 bytes
In article <1519@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
$A friend of mine has found something surprising in TC.  Neither of us knows
$C well enough to know for sure that this is a bug, but it looks like one.
$As illustrated in the program below, if a structure is an odd size, and
$is compiled with Word alignment, the sizeof function rounds the size up
$one byte.  
$Is this a bug?

   Well, it depends on how you define "bug" ... I don't have a copy of
K&R to check exactly what they say about it, but according to their
definition it may be.  However, it does make sense, since when compiled
with word alignment that extra byte is not available for anything
else and is allocated along with the structure.  Since it's reflecting
the way things really work, you could say it's the most accurate way
of doing it.
-- 
Stephen M. Dunn                               cs4g6ag@maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
               I Think I'm Going Bald - Caress of Steel, Rush
Technical Details
Message-ID: <25E9856C.8135@maccs.dcss.mcmaster.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!helios.physics.utoronto.ca!ists!yunexus!geac!maccs!cs4g6ag
References: <1519@maytag.waterloo.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!helios.physics.utoronto.ca!ists!yunexus!geac!maccs!cs4g6ag
From: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn)
Newsgroups: comp.sys.ibm.pc,comp.lang.c
Subject: Re: TC bug in sizeof()?
Message-ID: <25E9856C.8135@maccs.dcss.mcmaster.ca>
Date: 26 Feb 90 19:37:16 GMT
References: <1519@maytag.waterloo.edu>
Reply-To: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn)
Organization: McMaster University, Hamilton, Ontario
Lines: 20