Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83 (MC840302); site mcvax.UUCP
Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!guido
From: guido@mcvax.UUCP (Guido van Rossum)
Newsgroups: net.lang.c
Subject: Re: offsets in structures.
Message-ID: <6080@mcvax.UUCP>
Date: Wed, 10-Oct-84 14:17:40 EDT
Article-I.D.: mcvax.6080
Posted: Wed Oct 10 14:17:40 1984
Date-Received: Fri, 12-Oct-84 05:07:44 EDT
References: <393@orion.UUCP>
Reply-To: guido@mcvax.UUCP (Guido van Rossum)
Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam
Lines: 15
Summary: Don't be clever!

Watch out!  I did a similar thing to calculate the width of a structure:

	(int) ((struct foo *)0 + 1)

This would give me the sizeof a struct foo, ROUNDED UP to the necessary
alignment.  It worked fine, until one day, I ported my program to an
IBM PC with a Lattice C compiler.  There it would always evaluate to 1
(apparently the compiler cancelled the two casts against each other).

--
	Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam
	guido@mcvax.UUCP

"Immorality may be something, but it does not take the place of virtue
and three square meals a day."