[comp.unix.microport] Cnews on System V/AT: "expression causes compiler loop"

" Maynard) (11/19/89)

I'm trying to install C news, at the patchlevel 7/13 Nov 1989 level, on
my System V/AT 2.4 system. Trying to compile relay/hdrdefs.c, I get:

cc -I../include -I. -DVOID=int -DFLUSHEVERY=6 -O -c hdrdefs.c
"hdrdefs.c", line 49: compiler error: expression causes compiler loop:
try simplifying

I just tried it by hand, without the -O, and got the same error.

The relevant code is:
#ifndef offsetof
#define offsetof(type, mem) ((char *)&((type *)NULL)->mem - (char *)NULL)
#endif

static const char msgnm[] =	"Message-ID:";	/* for rejection */

static const struct hdrdef msghdr = {
	msgnm, STRLEN(msgnm), offsetof(struct headers, h_msgid) };

...with the last line being the one the compiler complains about.

Any ideas about how to simplify this one? Am I the only person to run
into this?

-- 
Jay Maynard, EMT-P, K5ZC, PP-ASEL   | Never ascribe to malice that which can
jay@splut.conmicro.com       (eieio)| adequately be explained by stupidity.
{attctc,bellcore}!texbell!splut!jay +----------------------------------------
Shall we try for comp.protocols.tcp-ip.eniac next, Richard? - Brandon Allbery

" Maynard) (11/19/89)

In article <3056@splut.conmicro.com> jay@splut.conmicro.com (Jay "you ignorant splut!" Maynard) writes:
>#define offsetof(type, mem) ((char *)&((type *)NULL)->mem - (char *)NULL)

Something just occurred to me, several hours after the original posting:
Was this the problem whose fix I gave Henry a hard time about a few months
ago about mixing pointers and integers?

-- 
Jay Maynard, EMT-P, K5ZC, PP-ASEL   | Never ascribe to malice that which can
jay@splut.conmicro.com       (eieio)| adequately be explained by stupidity.
{attctc,bellcore}!texbell!splut!jay +----------------------------------------
Shall we try for comp.protocols.tcp-ip.eniac next, Richard? - Brandon Allbery

mdm@cocktrice.UUCP (Mike Mitchell) (11/19/89)

In article <3056@splut.conmicro.com>, jay@splut.conmicro.com (Jay "you ignorant splut!" Maynard) writes:
> 
> I'm trying to install C news, at the patchlevel 7/13 Nov 1989 level, on
> my System V/AT 2.4 system. Trying to compile relay/hdrdefs.c, I get:
> 
> The relevant code is:
> #ifndef offsetof
> #define offsetof(type, mem) ((char *)&((type *)NULL)->mem - (char *)NULL)
> #endif
> 
> Any ideas about how to simplify this one? Am I the only person to run
> into this?
> 

#ifndef	offsetof
#define offsetof(type, mem) (int)&(((type *)0)->(mem))
#endif

Also be sure that you compile relaynews large model. It has the tendancy
to blow up on really huge incoming batches in small model. Use the dbz
routines in the contribution directory.

Cnews operates fairly well on one of these Uport '286 things.

-- 
Mike Mitchell                   BELL    H (505) 471-7639 W (505) 473-4482
2020 Calle Lorca #43            ARPA    mdm@cocktrice.UUCP
Santa Fe, NM 87505              UUCP    ...!uunet!dmk3b1!cocktrice!mdm

zeeff@b-tech.ann-arbor.mi.us (Jon Zeeff) (11/20/89)

>Cnews operates fairly well on one of these Uport '286 things.

I have a replacement rnews that gives me a 40+% speed improvement with C
News.  Anyone want to try it out and let me know if it works on a '286?

-- 
Jon Zeeff    		<zeeff@b-tech.ann-arbor.mi.us>
Branch Technology 	<zeeff@b-tech.mi.org>

It's 1989.  Does your software support the ISO 8859 character sets?

henry@utzoo.uucp (Henry Spencer) (11/21/89)

In article <3056@splut.conmicro.com> jay@splut.conmicro.com (Jay "you ignorant splut!" Maynard) writes:
>"hdrdefs.c", line 49: compiler error: expression causes compiler loop:
>try simplifying

The offsetof() macro has a tendency to stress-test compilers.  Try:

#define offsetof(type, mem) ((int)&((type *)NULL)->mem)

as an alternative.
-- 
A bit of tolerance is worth a  |     Henry Spencer at U of Toronto Zoology
megabyte of flaming.           | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (11/21/89)

In article <1989Nov20.181839.1546@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes:
| The offsetof() macro has a tendency to stress-test compilers.  Try:
| 
| #define offsetof(type, mem) ((int)&((type *)NULL)->mem)
| 
| as an alternative.

  I would be very careful using this. Althoug I feel that the use of a
zero cast to a non-void type is legal in sizeof, because of qualifying
statements promising that it is not evaluated, I would not be surprized
to see a compiler reject this one.

  I see how it works, I realize that it will work on many compilers, but
I am suspicious that it is not really portable. I would put the
definition in ifdefs at the very least, so that the required offsetof
macro could be used on undamaged compilers.

  The error message reminds me of things I used to get out of MSC some
years ago.
-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon