What is a constant expression

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Thu Oct 19 23:38:20 AEST 1989


In article <1989Oct18.224801.1767 at utzoo.uucp>, henry at utzoo.uucp (Henry Spencer) writes:
|  
|  Wonderful index, that... :-(  Try the table of contents:  section 3.4 is
|  all about constant expressions.  Unfortunately, subscripting a string isn't
|  one.

  I blush... I looked in the index and not the TOC. I suspect that I'm
not the only one who thinks the index should be about three times longer
than it is... I feel particularly dumb because I believe I quoted
footnote 44 as part of another posting on sizeof something with a NULL
pointer.

  While the wording in 3.4 is not explicit on this particular case, by
looking at what is allowed and forbidden I conclude that "abcd"[1] is
not treated as a character constant. It would be nice if it was, but it
is treated as if I had said:

	char nameless[] = "abcd";
	char foo = nameless[1];

which clearly isn't allowed for static init.

  I would like to know if the committee considered the indexed string
constant and decided not to make it a special case, or just didn't
think of it when doing this section. Obviously it's not one of the
common uses ;-)
-- 
bill davidsen	(davidsen at 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



More information about the Comp.std.c mailing list