TC bug in sizeof()?

Stephen M. Dunn cs4g6ag at maccs.dcss.mcmaster.ca
Tue Feb 27 06:37:16 AEST 1990


In article <1519 at maytag.waterloo.edu> dmurdoch at 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 at maccs.dcss.mcmaster.ca
          <std_disclaimer.h> = "\nI'm only an undergraduate!!!\n";
****************************************************************************
               I Think I'm Going Bald - Caress of Steel, Rush



More information about the Comp.lang.c mailing list