This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] mainline->branch merge status


Dale Johannesen <dalej@apple.com> writes:

> On Jan 29, 2004, at 3:12 AM, Andreas Schwab wrote:
>> This has the same problem.
>>
>>    { \
>>        *(void **) __o->next_free = (void *) datum; \
>>        __o->next_free += sizeof (void *); \
>>    } \
>
> True, cut and paste error.  But it still has the problems I mentioned
> before.

Which problems do you mean?

>>> can happen.  I believe the following is correct, performance neutral,
>>> and
>>> standard-conforming:
>>>
>>>        {
>>>        \
>>>         void ***t = (void ***)&(__o->next_free);
>>>         \
>>>          **t = ((void *)datum);
>>> \
>>>        (*t)++;
>>>        \
>>>       }                                            \
>>
>> I think this will break strict aliasing.
>
> So does the other way;  *(void **)__o->next_free = ... is exactly what you
> can't do.

I don't follow.  __o->next_free is a character pointer, thus can alias all
other pointers.  The problem with your version is, IIUC, that it converts
a (char **) into a (void ***), which cannot alias under the strict
aliasing rules, and the compiler can assume that (*t)++ does not modify
__o->next_free.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]