This is the mail archive of the gcc-help@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: (nessun oggetto)


This is not the right list to ask questions about the standard, this
list is for help using GCC.

On 10 October 2014 15:01, Graziano Servizi <Graziano.Servizi@bo.infn.it> wrote:
> I'm wondering in reading the 14.7.1.4  example of the standard, about
> template implicit instantiation: there it is found the following code
>
> template<class T> struct Z {
> void f();
> void g();
> };
> void h() {
> Z<int> a; // instantiation of class Z<int> required
> Z<char>* p; // instantiation of class Z<char> not required
> Z<double>* q; // instantiation of class Z<double> not required
> a.f(); // instantiation of Z<int>::f() required
> p->g(); // instantiation of class Z<char> required, and
>         // instantiation of Z<char>::g() required
> }
>
> followed by this comment:
>
> "Nothing in this example requires class
>
>  Z<double>, Z<int>::g(), or Z<char>::f()
>
>  to be implicitly instantiated."
>
>
> Almost all is clear enaugh to me, but my question is: does the line
>
> p->g();
>
> imply allocation of the pointer p to hold an address for the member function
> g ONLY?
>
> I didn't find any new operator before.
>
> And what about this pointer at the end of the expression? Is it implicitly
> released as well as it was "implicitly allocated"?
>
> Or all I wrote up to now is meaningless? ....

Yes, I think it's meaningless. There is no allocation or deallocation
in the example, it is only talking about template instantiation.

If the code was executed the expression p->g() would probably crash
because the pointer is uninitialized.


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