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]
Other format: [Raw text]

[Bug c++/15064] New: typeid of template parameter gives ICE


Simple templated function trying to take typeid of a template
parameter gives internal compiler error. The code simply reads:

#include <typeinfo>

using namespace std;

template <typename T>
void dummy() {
  const type_info & tid = typeid(T);
}

Environment:
System: Linux c3 2.4.21-199-default #1 Fri Mar 12 08:27:41 UTC 2004 i686 i686 i386 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.4.0/configure --prefix=/usr/local/new

How-To-Repeat:
Put the code above in test.cc and do 'gcc -v -save-temps -c test.cc'
which on my machine gives the output

============================= begin compiler output =========================
Reading specs from /mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --prefix=/usr/local/new
Thread model: posix
gcc version 3.4.0
 /mnt/server/local/9.0/new/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -E -quiet -v -iprefix /mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/ -D_GNU_SOURCE test.cc -mtune=pentiumpro -o test.ii
ignoring nonexistent directory "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory "/usr/local/new/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0"
ignoring duplicate directory "/usr/local/new/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu"
ignoring duplicate directory "/usr/local/new/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward"
ignoring duplicate directory "/usr/local/new/lib/gcc/i686-pc-linux-gnu/3.4.0/include"
ignoring nonexistent directory "/usr/local/new/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
 /mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
 /mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
 /mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/local/include
 /usr/local/new/include
 /usr/include
End of search list.
 /mnt/server/local/9.0/new/bin/../libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -fpreprocessed test.ii -quiet -dumpbase test.cc -mtune=pentiumpro -auxbase test -version -o test.s
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
	compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64367
test.cc: In function `void dummy()':
test.cc:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
============================= end compiler output =========================

Here comes the resulting test.ii file:

============================= begin test.ii ==================================
# 1 "test.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.cc"
# 1 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/typeinfo" 1 3
# 38 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/typeinfo" 3
# 1 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/exception" 1 3
# 40 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/exception" 3
extern "C++" {

namespace std
{
# 52 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/exception" 3
  class exception
  {
  public:
    exception() throw() { }
    virtual ~exception() throw();


    virtual const char* what() const throw();
  };



  class bad_exception : public exception
  {
  public:
    bad_exception() throw() { }


    virtual ~bad_exception() throw();
  };


  typedef void (*terminate_handler) ();

  typedef void (*unexpected_handler) ();


  terminate_handler set_terminate(terminate_handler) throw();


  void terminate() __attribute__ ((__noreturn__));


  unexpected_handler set_unexpected(unexpected_handler) throw();


  void unexpected() __attribute__ ((__noreturn__));
# 100 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/exception" 3
  bool uncaught_exception() throw();
}

namespace __gnu_cxx
{
# 115 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/exception" 3
  void __verbose_terminate_handler ();
}

}
# 39 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/typeinfo" 2 3

extern "C++" {

namespace __cxxabiv1
{
  class __class_type_info;
}
# 55 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/typeinfo" 3
namespace std
{






  class type_info
  {
  public:




    virtual ~type_info();

  private:

    type_info& operator=(const type_info&);
    type_info(const type_info&);

  protected:
    const char *__name;

  protected:
    explicit type_info(const char *__n): __name(__n) { }

  public:



    const char* name() const
    { return __name; }
# 101 "/mnt/server/local/9.0/new/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/typeinfo" 3
    bool before(const type_info& __arg) const
    { return __name < __arg.__name; }
    bool operator==(const type_info& __arg) const
    { return __name == __arg.__name; }

    bool operator!=(const type_info& __arg) const
    { return !operator==(__arg); }


  public:

    virtual bool __is_pointer_p() const;

    virtual bool __is_function_p() const;







    virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
       unsigned __outer) const;


    virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
        void **__obj_ptr) const;
  };






  class bad_cast : public exception
  {
  public:
    bad_cast() throw() { }


    virtual ~bad_cast() throw();
  };


  class bad_typeid : public exception
  {
  public:
    bad_typeid () throw() { }


    virtual ~bad_typeid() throw();
  };
}

}
# 2 "test.cc" 2

using namespace std;

template <typename T>
void dummy() {
  const type_info & tid = typeid(T);
}

============================= end test.ii ==================================

-- 
           Summary: typeid of template parameter gives ICE
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: leif dot lonnblad at thep dot lu dot se
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064


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