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]

Strange compilation errors.


When I compiled the following code with STRANGE_ERROR_MESSAGES defined
I got strange error messages :) :

template <typename> class H;
template <typename Target, typename Source>
H<Target> foo(const H<Source>&);

template <typename Type>
class H{

#ifndef STRANGE_ERROR_MESSAGES
public:
#endif
  template<template<class, class> class Caster, typename Source>
  static H<Type> cast(const H<Source>& s);

#ifdef STRANGE_ERROR_MESSAGES
  template <typename Target, typename Source>
  friend H<Target> foo(const H<Source>&);
#endif

};

template <class, class> class caster;

template <typename Target, typename Source>
H<Target> foo(const H<Source>& s){
  return H<Target>::template cast<caster, Source>(s);
}

int main(){
  H<int> i;
  foo<const int>(i);
}

Compiling it with the following command line produces:
eg++ -pedantic -c -Wall -DSTRANGE_ERROR_MESSAGES templates4.cc
templates4.cc: In function `class H<const int> foo(const class H<int>
&)':
templates4.cc:16:   instantiated from here
templates4.cc:26: no matching function for call to `H<int>::cast (const
H<int> &)'
templates4.cc:12: candidates are: H<int>::cast<template <class, class>
caster<{anonymous template type parm},{anonymous template type parm}>,
Source>(const H<Source> &)
templates4.cc:26: warning: control reaches end of non-void function
`foo(const H<int> &)'
eg++

eg++ -v
Reading specs from
/usr/local/egcs-19981005/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.92.13/specs

gcc version egcs-2.92.13 19981005 (gcc2 ss-980609 experimental)

Compiling it with the EGCS 1-1b release produces no compilation error
messages.

    I hope this helps.

    Erez.

--
----------------------------------------------------------------------
"The ships hung in the sky in much the same way that bricks don't."
        -- Douglas Adams / The Hitchhiker "Trilogy".





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