const in latest draft

Stan Friesen sarima at gryphon.COM
Mon Jun 5 03:08:10 AEST 1989


In article <10339 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <16259 at gryphon.COM> sarima at gryphon.COM (Stan Friesen) writes:
>
>[Answers to my questions]
>Yes.
>
>Yes.
>
>Yes.
>
	Thank-you, I needed that.

>>I am asking because I question the necessity of an implementation decision
>>made by Lattice Corp in version 3.4 of their C compiler, and I need to know
>>if my reasoning based on the Jan 11 draft is still valid.
>
>I don't know what Lattice has been up to; if you would tell us then perhaps
>we could directly address the specific issue.
>
	O.K.  I wanted to double-check my reasoning before I stuck my foot
in my mouth.  It seems my reasoning should be valid, so here goes.

	In the User's Guide to Lattice 3.4, in section 5.3.5, it states:
"ANSI has reserved 'const' to describe an object that never changes *within*
*the* *module* that declares it as 'const',...".  It then goes on to say:
"Notice that a 'const' object, using the ANSI definition, is not necessarily
unwritable.  For example, suppose you define a global data object that only
one function is supposed to change, while other functions need to read it.
The object should be declared *without* the 'const' keyword in the former
and *with* the 'const' keyword in the latter functions." [emphasis mine]
	From this they conclude that, to be ANSI compliant, they cannot
place 'const' objects in a seperate, ROMable CONST section, but that they
must be kept in the normal data section.  They have thus introduced a new
keyword, 'chip', for ROMable constants to be placed in the CONST section.
On the basis of the material I quoted from the Jan 11 Draft Standard, I
maintain this is *wrong*.  It is *undefined* to declare the same variable
both 'const' and non-'const', thus it is perfectly permissible for the
compiler to break if one tries this.  And it is certainly ANSI compliant to
place 'const' objects in a ROMable section.

	Luckily this perverse behavior is option controlled, rather than
unconditionally added.  Needless to say, I will never use the compiler in
the so-called ANSI mode with respect to 'const'.  I would rather keep *real*
ANSI compliance by placing 'const' stuff in a ROMable section.


	Lattice, are you out there and listening?
-- 
Sarima Cardolandion			sarima at gryphon.CTS.COM
aka Stanley Friesen			rutgers!marque!gryphon!sarima
					Sherman Oaks, CA



More information about the Comp.std.c mailing list