Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!deimos!uxc!uxc.cso.uiuc.edu!uxg.cso.uiuc.edu!uicsrd.csrd.uiuc.edu!mcdaniel
From: mcdaniel@uicsrd.csrd.uiuc.edu
Newsgroups: comp.std.c
Subject: A Little Quibble
Message-ID: <25200001@uicsrd.csrd.uiuc.edu>
Date: 8 Dec 88 06:14:00 GMT
Lines: 62
Nf-ID: #N:uicsrd.csrd.uiuc.edu:25200001:000:1755
Nf-From: uicsrd.csrd.uiuc.edu!mcdaniel    Dec  8 00:14:00 1988


Suppose I compile the following program under some dpANS C compiler:

    #include 
    main()
        {
	int a;
	a = 1;
	    {
	    int a = a;	/* X */
	    printf("a=%d\n", a);
	    }
	exit(0);
	}

Does dpANS require that "1" be printed, or is the result not defined
by dpANS?  In other words, in what environment is the right-hand-side
of line X evaluated?

Suppose I change line X to
	int b = a;    /* X' */
	int a = b;
Does the result change?  If the simplest translation
	int b, a;
	b = a; a = b;
is always done, the result is always undefined.

I ask this for two reasons:
- it's an interesting little quibble. :-)
- I would like to declare an invariant like this:
	double nubie;
	. . . compute nubie . . .
	{const double nubie = nubie;
	    . . . here, nubie is invariant . . .
	}

(I could also put "register" there to prevent passing "&nubie" to a
function to change it.  This use would only be for a compiler that is
smart enough to do its own register allocation, and ignore me totally.
:-)

By the way, here's another place where "typeof" would be convenient.
I could use
	#define FIX(x)	const typeof(x) x = x;
and code the example as
	{ FIX(nubie);
	. . . invariant nubie . . .
	}
Instead, I must use
	#define FIX(type, x)	const type x = x;
This is more error-prone, and it is harder to change the type of such
a FIXed variable.

--

             Tim, the Bizarre and Oddly-Dressed Enchanter

Center for      |||  Internet, BITNET:  mcdaniel@uicsrd.csrd.uiuc.edu
Supercomputing  |||  UUCP:     {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel
Research and    |||  ARPANET:  mcdaniel%uicsrd@uxc.cso.uiuc.edu
Development,    |||  CSNET:    mcdaniel%uicsrd@uiuc.csnet
U of Illinois   |||  DECnet:   GARCON::"mcdaniel@uicsrd.csrd.uiuc.edu"