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]

[Fwd: Compilation failed]





Hi,

Here is a program.
Its compilation failed.
Error message : no method ...
But the method exists (I think).

        Thanks in advance,
        Alex



//#########################################################
//------------------- C++ code : BEGIN -------------------

#include <iostream>

//============================
template<int m>
class AAA {};

//============================
template <int i, int j, bool b=(i<=j)>
class LoopFromTo {};

//============================
// Specialization-1
template <int i, int j>
class LoopFromTo<i, j, true>
{
        public:
                //-----------------------------
                template<template<int> class BBB>
                static void Exec()
                {

                        cout << __PRETTY_FUNCTION__ << endl;

                        LoopFromTo<i+1, j>::template Exec<BBB>(); // OK
                        LoopFromTo<i+1, i>::template Exec<BBB>(); // OK


                        //#######################################
                        // Compilation ERROR :  no method ...
                        LoopFromTo<4, 3>::template Exec<BBB>();
                        // But such a method exists
                        // See Specialization-2 for LoopFromTo
                        //#######################################


                        //#######################################
                        // This is also compiled OK
                        // LoopFromTo<2, 3>::template Exec<BBB>();
                        // LoopFromTo<3, 3>::template Exec<BBB>();
                        //#######################################
                }
};

//============================
// Specialization-2
template <int i, int j>
class LoopFromTo<i, j, false>
{
        public:
                //-----------------------------
                template<template<int> class BBB>
                static void Exec()
                {
                        cout << __PRETTY_FUNCTION__ << endl;
                }

};

int main()
{
        LoopFromTo<1,3>::template Exec<AAA>();
        cout << endl;

        return(0);
}


//------------------- C++ code : END ----------------------





//#########################################################
//------------------- Compilation Results : BEGIN ---------
%g++ -v bde1.C


Reading specs from
/tools/EGCS/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
 /tools/EGCS/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/cpp -lang-c++
-v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__
-D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix)
-Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc)
-Amachine(sparc) bde1.C /var/tmp/ccFe65nc.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /tools/EGCS/include/g++
 /tools/EGCS/sparc-sun-solaris2.6/include
 /tools/EGCS/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/include
 /usr/include
End of search list.
 /tools/EGCS/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/cc1plus
/var/tmp/ccFe65nc.ii -quiet -dumpbase bde1.cc -version -o
/var/tmp/ccG3Pxvz.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release)
(sparc-sun-solaris2.6) compiled by GNU C version egcs-2.91.57 19980901
(egcs-1.1 release).
bde1.C: In function `static void LoopFromTo<3,3,true>::Exec<BBB>()':
bde1.C:25:   instantiated from `LoopFromTo<2,3,true>::Exec<BBB>()'
bde1.C:25:   instantiated from `LoopFromTo<1,3,true>::Exec<template <int
const m> AAA<m>>()'
bde1.C:62:   instantiated from here
bde1.C:25: no method `LoopFromTo<4,3,false>::Exec<template <int const i,
int const j> template <int const {anon}> BBB>'
bde1.C:26: no method `LoopFromTo<4,3,false>::Exec<template <int const i,
int const j> template <int const {anon}> BBB>'
bde1.C:31: no method `LoopFromTo<4,3,false>::Exec<template <int const i,
int const j> template <int const {anon}> BBB>'
bde1.C: In function `static void LoopFromTo<2,3,true>::Exec<BBB>()':
bde1.C:25:   instantiated from `LoopFromTo<1,3,true>::Exec<template <int
const m> AAA<m>>()'
bde1.C:62:   instantiated from here
bde1.C:31: no method `LoopFromTo<4,3,false>::Exec<template <int const i,
int const j> template <int const {anon}> BBB>'
bde1.C: In function `static void LoopFromTo<1,3,true>::Exec<template
<int const m> AAA<m>>()':
bde1.C:62:   instantiated from here
bde1.C:31: no method `LoopFromTo<4,3,false>::Exec<template <int const i,
int const j> template <int const {anon}> BBB>'

//------------------- Compilation Results : END -----------






//#########################################################
//------------------- Compiler & System  ------------------

g++ -v     : gcc version egcs-2.91.57 19980901
             (egcs-1.1 release)

uname -a   : SunOS <nodename> 5.6 Generic_105181-09
             sun4m sparc SUNW,SPARCstation-5

//---------------------------------------------------------

//#########################################################







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