This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: There can be only one version_string
On Fri, Sep 20, 2002 at 08:55:48PM -0400, Kaveh R. Ghazi wrote:
> > From: Zack Weinberg <zack@codesourcery.com>
> > On Fri, Sep 20, 2002 at 06:31:37PM -0400, Kaveh R. Ghazi wrote:
> > >
> > > How is const char[] more memory efficient than const char *const ?
> >
> > const char[] is just the string; const char *const is the string and a
> > read-only pointer to that string.
>
> Hmm, I thought gcc optimized the latter into the former. Or maybe
> only with automatic variables? I could be wrong...
See for yourself -
$ cat test.c
const char *const x = "x";
const char y[] = "y";
$ ./xgcc -B./ -S test.c
$ cat test.s
.file "test.c"
.section .rodata
.LC0:
.string "x"
.globl x
.align 4
.type x, @object
.size x, 4
x:
.long .LC0
.globl y
.type y, @object
.size y, 2
y:
.string "y"
.ident "GCC: (GNU) 3.3 20020920 (experimental)"
zw