Subject: Re: CVS commit: syssrc
To: Matthew Jacob <mjacob@feral.com>
From: Jason R Thorpe <thorpej@zembu.com>
List: source-changes
Date: 12/30/2000 12:22:07
On Sat, Dec 30, 2000 at 11:47:53AM -0800, Matthew Jacob wrote:

 > Read my update. It is a bug somewher and not the code.
 > 
 > char *foo = "XXX"
 > 
 > is not
 > 
 > const char *foo = "XXX";

The Alpha compiler generates the following code for 'char *foo = "XXXX";':

	.globl foo
.section        .rodata
$LC0:
	.ascii "XXXX\0"
.data
	.align 3
foo:
	.quad $LC0
	.ident  "GCC: (GNU) egcs-2.91.66 19990314 (egcs-1.1.2 release)"

...and the same code for 'const char *foo = "XXXX";'.

If you change it to 'char foo[] = "XXXX";':

	.globl foo
.data
foo:
	.ascii "XXXX\0"
	.ident  "GCC: (GNU) egcs-2.91.66 19990314 (egcs-1.1.2 release)"

...and if you compile the first version with -fwritable-strings:

	.globl foo
.data
$LC0:
	.ascii "XXXX\0"
	.align 3
foo:
	.quad $LC0
	.ident  "GCC: (GNU) egcs-2.91.66 19990314 (egcs-1.1.2 release)"

This is one of the subtle semantic differences between * and [].

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>