c++/3518: [2003-05-03] default conversion to pointer-to-function is applied to soon (related to DR295)
giovannibajo@libero.it
giovannibajo@libero.it
Thu May 15 18:59:00 GMT 2003
Old Synopsis: [2003-05-03] default conversion applied too soon
New Synopsis: [2003-05-03] default conversion to pointer-to-function is applied to soon (related to DR295)
State-Changed-From-To: feedback->analyzed
State-Changed-By: bajo
State-Changed-When: Thu May 15 18:20:44 2003
State-Changed-Why:
Ok. I have submitted a new PR (c++/10807) with a testcase
suming up the whole DR295. This PR is directly related:
probably when DR295 is implemented correctly, this PR will
be fixed as well. Anyway, the final testcase for this PR
is:
-----------------------------------------------
template <typename T>
struct check_not_pointer {};
template <typename T>
struct check_not_pointer<T*>;
struct any
{
template <typename T> any (const T&)
{
check_not_pointer<T> dummy;
}
};
template <typename T> any Foo (const T &s)
{
return s;
}
void f ()
{}
int main()
{
Foo (f);
}
-----------------------------------------------
pr3518.cpp: In constructor `any::any(const T&) [with T = void (*)()]':
pr3518.cpp:17: instantiated from `any Foo(T&) [with T = void ()()]'
pr3518.cpp:25: instantiated from here
pr3518.cpp:11: error: `dummy' has incomplete type
pr3518.cpp:11: error: storage size of `dummy' isn't known
It fails because any::any should be instantiates with
[T = void (void)], while it gets instantiated with [T = void(*)(void)]
because the default conversion is applied too soon (and
DR295 is not implemented).
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=3518
More information about the Gcc-bugs
mailing list