This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
incorrect "no match" diagnostic
- To: bug-gcc at gnu dot org
- Subject: incorrect "no match" diagnostic
- From: wb at fncrdg dot fnal dot gov (Walter Brown)
- Date: Fri, 24 Dec 1999 15:24:37 -0600 (CST)
- Mailing-Address: MS 234 / Batavia, IL 60510-0500 / USA
- Organization: Fermi National Accelerator Laboratory
- Phone: +1 630.840-2784
- Reply-To: wb at fnal dot gov
This is a multi-part message in MIME format.
--------------7CBD559CFA72B6C2CF011885
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello,
Using gcc 2.95.2: g++ -pedantic test.cpp -o test.exe
the attached program results in a diagnostic as commented inline. I
believe this diagnostic is incorrect, and would appreciate any advice
you might have to circumvent this problem. If the problem is known and
a patch exists, I would be grateful for a pointer to same.
Thank you, and best wishes of the season to one and all.
- WEB
--------------7CBD559CFA72B6C2CF011885
Content-Type: text/plain; charset=us-ascii;
name="test.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test.cpp"
// ----------------------------------------------------------------------
template< int N > class C {
public:
enum { n = N };
C() { ; }
}; // C<n>
template< int n1, int n2 >
inline C<n1+n2>
operator * ( C<n1> c1, C<n2> c2 ) { return C<n1+n2>(); }
// ----------------------------------------------------------------------
template< class T, T (*G)() > class S {
public:
inline operator T () const { return (*G)(); }
inline T operator () () const { return (*G)(); }
}; // S<T,g>
template< class T, T (*G)()
, class U, U (*H)() >
inline C<int(T::n)+int(U::n)>
operator * ( S<T,G> s1 , S<U,H> s2 ) {
static_cast<void>( s1(), s2() );
return C<int(T::n)+int(U::n)>();
} // op*<>()
// ----------------------------------------------------------------------
C<1> c1Gen() {
static C<1> const c1;
return c1;
}
S< C<1>, &c1Gen > s1;
// ----------------------------------------------------------------------
C<2> c2Gen() {
static C<2> const c2( C<1>() * C<1>() );
return c2;
}
S< C<2>, &c2Gen > s2;
// ----------------------------------------------------------------------
C<3> c3Gen() {
static C<3> const c3( C<1>() * C<2>() );
return c3;
}
S< C<3>, &c3Gen > s3;
// ----------------------------------------------------------------------
int main() {
C<1> c1; C<2> c2; c1 * c2;
C<3> c3( s3 );
// GCC 2.95.2: why do you report that there is "no match" for
// the following right-hand side operator *() ?
c3 = s1 * s2;
return 0;
} // main()
--------------7CBD559CFA72B6C2CF011885--