which compiler is right (either to compile or to barf)...

leon zadorin leonleon77@gmail.com
Fri Dec 2 09:16:09 GMT 2022


Sorry, just one more question :)

So if we have

static ::std::foo<S> f;

and  foo indeed considers S to be complete... is it then permitted to
reference S's members and call S's member functions (like dtor()) in foo's
constructor?

I guess a silly consideration would be foo's constructor where it would
create a temporary S and destroy it (for no specific reason other than to
illustrate a point)... e.g.

foo::foo() {
    S tmp;
}

now... if S type had a member of vector with incomplete type and standard
allows for vector itself to be instantiated but not its members when T is
incomplete as per vector.overview] 4) ... then at a time of '~S' (tmp being
destructed) would not vector's destructor also be called? ... and at that
point in time will it not reference the members of vector?

Perhaps I am confusing myself with 'instantiation' of template types vs
'creation' of variables... at a time of 'static ::std::foo<S> f', i.e. the
'f' variable being actually created... the S.v (our vector of incomplete
type) would already be instantiated/type-complete (as in: concrete type
inferred from template processing)?

Sorry for all the naive questions here -- haven't dived into this thinking
for a while... getting old :)


More information about the Gcc-help mailing list