Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: Ian Lance Taylor <ian@airs.com>
From: Greg A. Woods <woods@weird.com>
List: tech-toolchain
Date: 07/16/2003 02:41:17
[ On , July 14, 2003 at 17:37:46 (-0700), Ian Lance Taylor wrote: ]
> Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
>
> Using `char foo[] = "string"' does de-const the string. It creates a
> modifiable array, and initializes it with the string constant. The
> string winds up in .data rather than .rodata.
Ah, OK, thanks for clarifying that trick really does do the right thing,
at least with GCC, I assume.
However so far as I can tell (from informal sources -- I've not got a
copy of the final C standard) such treatment of string constants in
array initializers like that in the example above is not strictly
compliant with Standard C. From what I read in Harbison and Steele all
string constants have the type "const char []" and _may_ be allocated in
read-only storage.
--
Greg A. Woods
+1 416 218-0098 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com> Secrets of the Weird <woods@weird.com>