This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/18814] Incorrect reinitialization of compound literal
- From: "austern at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Dec 2004 19:27:46 -0000
- Subject: [Bug c/18814] Incorrect reinitialization of compound literal
- References: <20041203183239.18814.austern@apple.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From austern at apple dot com 2004-12-03 19:27 -------
Subject: Re: Incorrect reinitialization of compound literal
On Dec 3, 2004, at 11:15 AM, pinskia at gcc dot gnu dot org wrote:
>
> ------- Additional Comments From pinskia at gcc dot gnu dot org
> 2004-12-03 19:15 -------
> (In reply to comment #4)
>> Subject: Re: Incorrect reinitialization of compound literal
>>
>> On Dec 3, 2004, at 10:50 AM, pinskia at gcc dot gnu dot org wrote:
>>
>>>
>>> ------- Additional Comments From pinskia at gcc dot gnu dot org
>>> 2004-12-03 18:50 -------
>>> But reading 6.5.2.5 P 16 seems to say something different.
>>>
>>> What it seems to say is:
>>> p = &((int) {1});
>>> is to set the int to be one and then take the address. We still
>>> point
>>> to the same int as before.
>>
>> Not exactly. We still point to the same (one-element) array of ints
>> we
>> did before. The array is modifiable, and we're changing the value of
>> the first element in the array. You might think that we should be
>> reinitializing the object, but that's wrong. When we execute that
>> statement a second time all we're doing is setting p to the address of
>> the compound literal again, but we have change the value of that
>> compound literal.
>
> But it is not clear to me at least we should reinitialize the literal,
> because the example which I gave
> shows it should but you say it should not.
The example you gave isn't relevant. It says that we don't create a
new object. It says nothing about modifying the original literal,
which is what we're doing.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18814