This is the mail archive of the gcc-bugs@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]

A problem of template implicit instantiation


HI,

I have a piece of code at "http://goo.gl/r2ySE6";

Refer to the code, with option of "-O2 -std=c++1y", when we comment
out the statement "id<int>;" clang-3.4.1 compiles the code
successfully, but g++-4.9.0 compiles failed, where g++ complains that
"unresolved overloaded function type", which in turn implies that at
the point of calling compose function, id<int> is not instantiated.

"3. Unless a function template specialization has been explicitly
instantiated or explicitly specialized, *the function template
specialization is implicitly instantiated  when the specialization is
referenced in a context that requires a function definition to exist.*
"[temp.inst]

At the point of calling the compose function, the function definition
for id<int> is required, and so, id<int> should be implicitly
instantiated.

Based on my argument, it is a bug in g++-4.9.0, but I am not 100% sure
of it. Please advice.

PS: Yongwei Wu is credited for discovering the problem.


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