To const or not to const...

Jan-Benedict Glaw jbglaw@lug-owl.de
Thu Feb 20 14:27:00 GMT 2003


Hi!

After playing a bit with macros, I came to some construct I don't fully
understand (or gcc does something bad with it. Here's my testcase:

int a = "hello"[2]; /* #1 */
int main() {
	int b = "again_hello"[5]; /* #2 */
	return 0;
}


Assignment #2 is okay from GCC's eyes, but #1 isn't:

t2.c:2: initializer element is not constant

Sure, what I try is "uncommon" (to the best), but I think that
'"hello"[2]' is a constant value which could be examined. For the
curious, gcc accepts this construct for the second assignment...

The behaviour is the same with gcc-2.95 and gcc-3.0.

MfG, JBG

-- 
   Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur
    fuer einen Freien Staat voll Freier Bürger" | im Internet!
   Shell Script APT-Proxy: http://lug-owl.de/~jbglaw/software/ap2/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20030220/e6e814ad/attachment.sig>


More information about the Gcc mailing list