🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Phil Dykstra Thu, 06 Oct 1988 12:57
constant expression folding problem?
#1754
Author: Phil Dykstra
Date: Thu, 06 Oct 1988 12:57
31 lines
1167 bytes
gcc 1.28  Sun 3/50  SunOS 3.5

The following code:
============================
struct test {
	char	s[32];
	int	i;
};
#define TEST_NULL	((struct test *)0)

char *foo = (char *)(TEST_NULL->s);

main()
{
}
============================
causes:
t.c:7: initializer for static variable is not constant

There is apparently something about that expression that the
constant folder can't reduce.  The Cray C compiler used
to die on this same sort of expression, but they fixed it.
I know of many other C compilers that accept it as well
(Sun, SGI, Alliant, Gould, Convex, Ardent, Pyramid, BSD Vax).
It would be nice if gcc could too.

- Phil

[The code may look terrible, but doing things sort of like this
is important for code that parses and fills in dynamic C data
structures!]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads