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]

Another parser bug with templates


I've found another parser bug.  The test case is the following:

================== file: tmpfunc.cc =====================
#include <functional>

template <class T>
void do_nothing(const T& arg) 
{
  class doit : public binary_function<T, T, bool> {
    public:
      const T& goo;
      doit(const T& old) : goo(old) {};
      bool operator()(const T& a, const T& b) { return a == b; };
  };
  doit ok(arg);
  cout << ok(arg,arg);
}
================== end file =====================

egcs result:
% g++ -v -W -Wall -g -O -c tmpfunc.cc 
Reading specs from /home/thog/leven/egcs-1.0.2/i386/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.27/specs
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
 /home/thog/leven/egcs-1.0.2/i386/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.27/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Di386 -D__ELF__ -Dunix -Dlinux -D__i386__ -D__ELF__ -D__unix__ -D__linux__ -D__i386 -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -D__OPTIMIZE__ -g -W -Wall -Di386 -Di586 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -D__i586__ -Asystem(unix) -Acpu(i386) -Amachine(i386) tmpfunc.cc /var/tmp/cca08068.ii
GNU CPP version egcs-2.90.27 980315 (egcs-1.0.2 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /home/thog/leven/egcs-1.0.2/include/g++
 /usr/local/include
 /home/thog/leven/egcs-1.0.2/i386/i586-pc-linux-gnu/include
 /home/thog/leven/egcs-1.0.2/i386/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.27/include
 /usr/include
End of search list.
 /home/thog/leven/egcs-1.0.2/i386/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.27/cc1plus /var/tmp/cca08068.ii -quiet -dumpbase tmpfunc.cc -g -O -W -Wall -version -o /var/tmp/cca08068.s
GNU C++ version egcs-2.90.27 980315 (egcs-1.0.2 release) (i586-pc-linux-gnu) compiled by GNU C version egcs-2.90.27 980315 (egcs-1.0.2 release).
tmpfunc.cc: In function `void do_nothing(const T &)':
tmpfunc.cc:6: Internal compiler error.
tmpfunc.cc:6: Please submit a full bug report to `egcs-bugs@cygnus.com'.

I get a similar result with gcc-2.8.1.  The code compiles with gcc-2.7.2.3.
It doesn't matter whether "class doit" is derived from binary_function
or not.  If the function is not a template, there is no problem, nor is
there a problem if the class is defined outside the function.


-Peter

P.S.  There is a bug in the 'gcc/objc/pthreads.c' file:  it attempts to
      include the file "pcthread.h" when it should be including 
      "pthread.h"

P.P.S.  Where is this option documented (i.e., for which (class of) targets 
	is it useful, and for which targets is not)?

      --enable-haifa -- Enable the new Haifa instruction scheduler in the
      compiler; the new scheduler can significantly improve code on some
      targets.  --disable-haifa is currently the default on all platforms
      except the HPPA.

-- 
**********************************************************************
*   Peter Leven                          *  p-leven@uiuc.edu         * 
**  Lehrstuhl fuer Prozessrechner        *  Beckman Institute       **
**  Technische Universitaet Muenchen     *  Universitaet Illinois   **
*   http://www.uiuc.edu/ph/www/p-leven   *                           *
**********************************************************************


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