Solaris 2.5.1, gcc version 2.96 200006021; typedef not recognized
Jim McKelvey
mckelvey@bean.jpl.nasa.gov
Mon Jun 26 14:47:00 GMT 2000
In code below, method get_variable must reference typedef base_type as
Value<T>::base_type, otherwise a syntax error is emitted. That makes no sense,
since get_variable is a method of the template, and base_type is allowed without
qualification in the constructor.
Adding "typename" makes no difference.
template <class T>
class Value
{
public:
typedef T base_type;
inline explicit Value(const base_type& variable);
const base_type& get_variable(void) const;
private:
base_type _variable;
};
template <class T>
Value<T>::
Value<T>(const base_type& variable)
:
_variable(variable)
{
}
template <class T>
const base_type& Value<T>::
//const Value<T>::base_type& Value<T>::
get_variable(void) const
{
return _variable;
}
mushroom...private>g++ -v -c Value.cc
Reading specs from
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/specs
gcc version 2.96 20000621 (experimental)
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=96
-D__GNUC_PATCHLEVEL__=0 -D__cplusplus -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) Value.cc /var/tmp/cc5dWmsZ.ii
GNU CPP version 2.96 20000621 (experimental) (cpplib)
(sparc)
#include "..." search starts here:
#include <...> search starts here:
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/include/g++-3
/usr/local/include
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/include
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/sparc-sun-solaris2.5.1/include
/usr/include
End of search list.
/afs/jpl.nasa.gov/home/m/mckelvey/public/Software/lib/gcc-lib/sparc-sun-solaris2
.5.1/2.96/cc1plus /var/tmp/cc5dWmsZ.ii -quiet -dumpbase Value.cc -version -o
/var/tmp/ccyDyD7R.s
GNU C++ version 2.96 20000621 (experimental) (sparc-sun-solaris2.5.1) compiled
by GNU C version 2.96 20000621 (experimental).
Value.cc:32: syntax error before `&'
Value.cc:32: `T' was not declared in this scope
Value.cc:32: template argument 1 is invalid
Value.cc:36: ISO C++ forbids declaration of `get_variable' with no type
Value.cc:36: non-member function `get_variable ()' cannot have `const'
method qualifier
Value.cc: In function `int &get_variable ()':
Value.cc:37: `_variable' undeclared (first use this function)
Value.cc:37: (Each undeclared identifier is reported only once for each
function it appears in.)
mushroom...private>
More information about the Gcc-bugs
mailing list