This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Internal error in static cast of templated function
- To: egcs-bugs at cygnus dot com
- Subject: Internal error in static cast of templated function
- From: Carl Kumaradas <ckumarad at oci dot utoronto dot ca>
- Date: 13 Nov 1997 20:53:47 -0500
- Cc: ckumarad at oci dot utoronto dot ca
For the following file:
#include <vector>
#include <numeric>
#ifdef INC_FUNCTIONAL
#include <functional>
#endif
template<class R> int p( int val, R& r )
{
return val + r;
}
template<class R> void f( vector<R>& v )
{
#ifdef USE_STATIC_CAST
accumulate( v.begin(), v.end(), 0, static_cast<int (*)(int, R&)>(p) );
#else
accumulate( v.begin(), v.end(), 0, p<R> );
#endif
}
main()
{
vector<int> r;
f( r );
}
I get the following errors (the last one would be a real bug I guess):
kelvin:~/tmp > g++ test_num.cc
test_num.cc: In function `void f<int>(class vector<int,__default_alloc_template<false,0> > &)':
test_num.cc:17: no matching function for call to `accumulate (int *, int *, int, {unknown type})'
kelvin:~/tmp > g++ -DINC_FUNCTIONAL test_num.cc
test_num.cc: In function `void f<int>(class vector<int,__default_alloc_template<false,0> > &)':
test_num.cc:17: no matching function for call to `accumulate (int *, int *, int, {unknown type})'
kelvin:~/tmp > g++ -DUSE_STATIC_CAST test_num.cc
test_num.cc: In function `void f<int>(class vector<int,__default_alloc_template<false,0> > &)':
test_num.cc:15: cannot resolve overloaded function `p' based on non-function type
kelvin:~/tmp > g++ -DINC_FUNCTIONAL -DUSE_STATIC_CAST test_num.cc
test_num.cc: In function `void f<int>(class vector<int,__default_alloc_template<false,0> > &)':
test_num.cc:15: Internal compiler error.
test_num.cc:15: Please submit a full bug report to `egcs-bugs@cygnus.com'.
kelvin:~/tmp > g++ -v
Reading specs from /usr/unsup/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.90.16/specs
gcc version egcs-2.90.16 971105 (gcc2-970802 experimental)
Line 15 is the 1st line with "accumulate()" and line 17 is the 2nd.
Is the static cast correct? Should the explict template parameter
(p<R>) work. I get the internal error only when I include
<functional> (I included it by mistake).
With SGI IRIX CC v7.1 plus STL 3.0 (from SGI), it compiles fine for
the static cast case regardless of if <functional> is included.
Any ideas on how I can get this to compile with the currect egcs?
Thanks fro any help,
Carl.
--
J. Carl Kumaradas Ontario Cancer Institute
ckumarad@oci.utoronto.ca University of Toronto