public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52768] New: Unable to get pointer to template function
@ 2012-03-29 12:24 kmakaron11 at gmail dot com
2012-03-29 13:09 ` [Bug c++/52768] " redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: kmakaron11 at gmail dot com @ 2012-03-29 12:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52768
Bug #: 52768
Summary: Unable to get pointer to template function
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kmakaron11@gmail.com
GCC 4.6.3, as well as GCC 4.8 cannot resolve template method, even if it is
explicitly instantiated.
The code to explain the problem is:
template <class T>
struct Creator
{
template <typename...Ts>
static std::shared_ptr<T> create(Ts&&... vs)
{
std::shared_ptr<T> t(new T(std::forward<Ts>(vs)...));
return t;
}
};
class Car:
public Creator<Car>
{
private:
friend class Creator<Car>;
Car()
{
}
};
int main()
{
std::function< std::shared_ptr<Car> () > createFn=&Car::create<>;
return 0;
}
This results in following compiler error:
error: conversion from ‘<unresolved overloaded function type>’
to non-scalar type ‘std::function<std::shared_ptr<Car>()>’ requested
However it compiles fine on Clang3.0 and 3.1.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52768] Unable to get pointer to template function
2012-03-29 12:24 [Bug c++/52768] New: Unable to get pointer to template function kmakaron11 at gmail dot com
@ 2012-03-29 13:09 ` redi at gcc dot gnu.org
2012-03-29 13:13 ` [Bug c++/52768] cannot resolve address of function template with empty template argument list redi at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-29 13:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52768
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-29 13:02:14 UTC ---
(In reply to comment #0)
> The code to explain the problem is:
No it isn't, it's missing several include files. I know it's "obvious" which
ones they are, but if five different people all look at the bug report and try
to reproduce the behaviour then they all have to figure it out and modify the
code. You'd save everyone time by providing a *complete* testcase, as clearly
requested by the bug submissions guidelines.
A complete example would be:
template<typename Res>
struct function
{
template<typename F> function(F) { }
};
template <class T>
struct Creator
{
template <typename...Ts>
static T* create(Ts&&... vs)
{
return new T(vs...);
}
};
class Car:
public Creator<Car>
{
private:
friend class Creator<Car>;
Car() { }
};
int main()
{
function< Car* () > createFn=&Car::create<>;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52768] cannot resolve address of function template with empty template argument list
2012-03-29 12:24 [Bug c++/52768] New: Unable to get pointer to template function kmakaron11 at gmail dot com
2012-03-29 13:09 ` [Bug c++/52768] " redi at gcc dot gnu.org
@ 2012-03-29 13:13 ` redi at gcc dot gnu.org
2012-03-29 13:30 ` kmakaron11 at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-29 13:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52768
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-03-29
Summary|Unable to get pointer to |cannot resolve address of
|template function |function template with
| |empty template argument
| |list
Ever Confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-29 13:09:10 UTC ---
Same problem using a default template argument instead of a parameter pack:
template<typename Res>
struct function
{
template<typename F> function(F) { }
};
template <class T>
struct Creator
{
template <typename Ts = int>
static T* create(Ts vs)
{
return new T(vs);
}
};
class Car:
public Creator<Car>
{
private:
friend class Creator<Car>;
Car(int) { }
};
int main()
{
function< Car* () > createFn=&Car::create<>;
}
(technically this is a C++11 bug, but G++ supports variadic templates and
default template arguments for functions in c++98 mode)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52768] cannot resolve address of function template with empty template argument list
2012-03-29 12:24 [Bug c++/52768] New: Unable to get pointer to template function kmakaron11 at gmail dot com
2012-03-29 13:09 ` [Bug c++/52768] " redi at gcc dot gnu.org
2012-03-29 13:13 ` [Bug c++/52768] cannot resolve address of function template with empty template argument list redi at gcc dot gnu.org
@ 2012-03-29 13:30 ` kmakaron11 at gmail dot com
2012-03-29 13:31 ` redi at gcc dot gnu.org
2013-05-25 15:38 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: kmakaron11 at gmail dot com @ 2012-03-29 13:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52768
--- Comment #3 from kmakaron11 at gmail dot com 2012-03-29 13:25:11 UTC ---
I am sorry, Jonathan Wakely. This is my first GCC bug report.
Next time I will, try to put the fallout to minimum.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52768] cannot resolve address of function template with empty template argument list
2012-03-29 12:24 [Bug c++/52768] New: Unable to get pointer to template function kmakaron11 at gmail dot com
` (2 preceding siblings ...)
2012-03-29 13:30 ` kmakaron11 at gmail dot com
@ 2012-03-29 13:31 ` redi at gcc dot gnu.org
2013-05-25 15:38 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-29 13:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52768
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-29 13:30:28 UTC ---
Even more reason to read http://gcc.gnu.org/bugs/ first then :)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52768] cannot resolve address of function template with empty template argument list
2012-03-29 12:24 [Bug c++/52768] New: Unable to get pointer to template function kmakaron11 at gmail dot com
` (3 preceding siblings ...)
2012-03-29 13:31 ` redi at gcc dot gnu.org
@ 2013-05-25 15:38 ` paolo.carlini at oracle dot com
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-25 15:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52768
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.8.0, 4.9.0
Resolution|--- |FIXED
Target Milestone|--- |4.8.0
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is fixed in 4.8.0.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-25 15:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 12:24 [Bug c++/52768] New: Unable to get pointer to template function kmakaron11 at gmail dot com
2012-03-29 13:09 ` [Bug c++/52768] " redi at gcc dot gnu.org
2012-03-29 13:13 ` [Bug c++/52768] cannot resolve address of function template with empty template argument list redi at gcc dot gnu.org
2012-03-29 13:30 ` kmakaron11 at gmail dot com
2012-03-29 13:31 ` redi at gcc dot gnu.org
2013-05-25 15:38 ` paolo.carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).