This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Strenghten assumption about dynamic type changes (placement new)
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 3 Jul 2014 02:56:20 +0200
- Subject: Re: Strenghten assumption about dynamic type changes (placement new)
- Authentication-results: sourceware.org; auth=none
- References: <20140702201805 dot GB15987 at kam dot mff dot cuni dot cz> <53B49446 dot 7090402 at redhat dot com>
> On 07/02/2014 01:18 PM, Jan Hubicka wrote:
> >We propagate types from places we know instances are created across pointers
> >passed to functions. Once non-POD type is created at a given memory location,
> >one can not change its type by placement_new into something else.
>
> Hmm. If the memory location is untyped (i.e. from malloc) or a
> character array, or a union, you can indeed destroy an object of one
> type and create an object of a different type in that location.
>
> >Jason, this assumes that one can not destroy the type and re-construct same
> >type at the same spot.
>
> That is an invalid assumption; you can destroy one object and
> construct a new one in the same location. Doing it within a method
> would be unusual, but I don't think there's a rule against it.
The types get currently are one comming from declarations of variables
and parameters passed by reference.
Can I really destroy it/allocate new type/destroy new type/allocate back the original
type (or terminate the program) so the destruction at the end of the lifetimate of the
variable apsses?
I suppose we should keep track if memory location is comming from declaration or
it is dynamically typed (i.e. type seen from calling constructor)? Currently we don't
deal with dynamic types, but I have patches for that.
Honza
>
> Jason