This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: More function decorations II (pool_allocator, mt_allocator, debug, stl_list)


On Wed, 22 Apr 2009, Gabriel Dos Reis wrote:

> Yes, but they also share this:
> 
>     struct Complex {
>        double re;
>        double im;
>     };
> 
>     Complex* newComplex() {
>        Complex* p = (Complex*) malloc(sizeof (Complex));
>        p->re = 0;
>        p-> im = 0;
>     }
> 
>     int main(void) {
>        Complex* p = newComplex();
>        *(double*)p = 9.0;     // #1
>         return p->im;
>     }
> 
> I don't think #1 ends the lifetime of  the object pointed to by
> `p' either.  The point here is that you have to factor in together
> all the various places that allow accessing an object value
> with different types other than the dynamic of effective types.
> (3.10/15 in particular).

I always find the "an aggregate or union type ..." clause confusing
as that suggests it is ok to access double x; via an lvalue of
type Complex while I am sure the opposite is meant - the lvalue
is of type of a member of the object type.

Richard.


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