[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: CVS commit: pcc-libs/libpcc
From:       Gregory McGarry <greg () bitlynx ! com>
Date:       2008-12-15 19:32:01
Message-ID: 85C40D36-EA3E-47F4-9561-C46A05A935B5 () bitlynx ! com
[Download RAW message or body]


On 16/12/2008, at 1:34 AM, Otto Moerbeek wrote:

> On Mon, Dec 15, 2008 at 02:06:55PM +0100, Otto Moerbeek wrote:
>
>> Of course it is wrong to demonstrate a language feature by showing
>> compiler output. But it does not matter. What matters is that in both
>> cases the address of the string is the arg to write(), and not the
>> string itself.
>
> Ugh, now I realize we were talking about different things. I was
> talking abot parameter passing and you about the var and it's
> initialization itself. Sorry for the confusion.
>
> For an auto array constness matters:
>
> f(void)
> {
> 	char myarray[] = "foo";
> }
>
> should allocate 4 bytes on the stack and upon fuction entry these
> should be initialized.
>
> if myarray is declared as:
>
> 	const char myarray[] = "foo";
> 	
> it should be possible to do an optimization: for a const array with an
> initializer having all elements constant expressions (which is the
> case for a string literal) there's no need to copy, and myarray can
> refer to a piece of (r/o) data.

Yes, I agree with you here.  It's an optimization which gcc doesn't  
do either.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic