BSD C compiler bug

Chris Torek chris at mimsy.UUCP
Tue Mar 22 04:22:17 AEST 1988


>In article <10747 at mimsy.UUCP> I said
[	char *p; p = (0, 0); ]
>>The 11 Jan 1988 draft of the dpANS [disallows `,' in] constant
>>expressions (p. 56):

In article <7507 at brl-smoke.ARPA> gwyn at brl-smoke.ARPA (Doug Gwyn) writes:
>What do constant expressions have to do with it?

Constant expressions have *everything* to do with it!

How do you create a nil pointer of type T in C?  Answer: put the
integer constant `0' in a pointer context (assignment or comparison, or
[dpANS] argument to a function that has a prototype in scope).  What is
`the integer constant 0'?  Clearly this is any constant expression
whose value is zero and whose type is one of the integral types {char,
short, int, long} or their signed or unsigned variants.  The
expression

	(0, 0)

certainly has the value zero and an integral type, but according to
the dpANS, it is not a constant expression.  Hence it cannot be `the
integer constant zero'; it is merely an integer expression whose value
is zero.  The situation is thus the same as if one were to write

	char *p;
	int zero = 0;
	p = zero;

I have not found anything in the draft standard to contradict
this reasoning.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list