On 06/15/2015 11:13 AM, Andrew Pinski wrote:
> On Mon, Jun 15, 2015 at 2:09 AM, Martin Liška <[email protected]> wrote:
>> On 06/11/2015 08:19 PM, Richard Biener wrote:
>>> On June 11, 2015 7:50:36 PM GMT+02:00, Jakub Jelinek <[email protected]>
>>> wrote:
>>>> On Fri, Jun 12, 2015 at 12:58:12AM +0800, [email protected] wrote:
>>>>> This is just a bug in the older compiler. There was a change to fix
>>>> in
>>>>> placement new operator. I can't find the reference right now but
>>>> this is
>>>>> the same issue as that.
>>>>
>>>> I'm not claiming 4.1 is aliasing bug free, there are various known
>>>> issues in
>>>> it. But, is that the case here?
>>>>
>>>> empty_var = onepart_pool (onepart).allocate ();
>>>> empty_var->dv = dv;
>>>> empty_var->refcount = 1;
>>>> empty_var->n_var_parts = 0;
>>>>
>>>> doesn't really seem to use operator new at all, so I'd say the bug is
>>>> in
>>>> all the spots that call allocate () method of the pool, but don't
>>>> really
>>>> use operator new.
>>>
>>> Yeah. BTW, I see the same issue on x86_64 and on ia64 with a gcc 4.1 host
>>> compiler. I think allocate itself should use placement new, not just a
>>> static pointer conversion.
>>>
>>> Richard.
>>
>> Hi.
>>
>> What do you mean by calling placement new? Currently
>> pool_allocator<T>::allocate calls placement new as a last statement in the
>> function:
>>
>> return (T *)(header);
>
> That is only a cast and not a placement new.
> Try this instead:
> return new(header) T();
Ah, I overlooked that it's not a placement new, but just static casting.
Anyway, if I added:
cselib_val () {}
to struct cselib_val and changed the cast to placement new:
char *ptr = (char *) header;
return new (ptr) T ();
I got following compilation error:
In file included from ../../gcc/alias.c:46:0:
../../gcc/alloc-pool.h: In instantiation of ‘T* pool_allocator<T>::allocate()
[with T = cselib_val]’:
../../gcc/cselib.h:51:27: required from here
../../gcc/alloc-pool.h:416:23: error: no matching function for call to
‘cselib_val::operator new(sizetype, char*&)’
return new (ptr) T ();
^
In file included from ../../gcc/alias.c:47:0:
../../gcc/cselib.h:49:16: note: candidate: static void* cselib_val::operator
new(size_t)
inline void *operator new (size_t)
^
../../gcc/cselib.h:49:16: note: candidate expects 1 argument, 2 provided
I am wondering if I can combine overwritten new operator, which is going to
internally use placement new with a default
ctor?
Martin
>
> Thanks,
> Andrew
>
>>
>> Martin
>>
>>>
>>>> Jakub
>>>
>>>
>>