This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26417] New: typeid(typeid(*object)) ICE on g++ 3.x / i686
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Feb 2006 13:30:00 -0000
- Subject: [Bug c++/26417] New: typeid(typeid(*object)) ICE on g++ 3.x / i686
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The code below generates a compiler ICE with g++ 3.3 (debian stable),
g++ 3.4 (debian testing):
[pollindd] ~ >g++-3.3 -c ice-typeid.cc
1036
ice-typeid.cc: In function `int bug5(BaseB*)':
ice-typeid.cc:43: internal compiler error: in expand_expr, at expr.c:8833
Please submit a full bug ...
[pollindd] ~ >g++-3.4 -c ice-typeid.cc
1037
ice-typeid.cc: In function `int bug5(BaseB*)':
ice-typeid.cc:43: internal compiler error: in expand_expr_real, at
expr.c:8469
Please submit a full bug report...
It works well with g++ 2.95.4 (debian). Maybe related to bug #25357.
Environment:
System: Linux pollindd 2.6.15.2-adeos #2 PREEMPT Wed Feb 15 12:00:00 CET
2006 i686 GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4
--enable-shared --with-system-zlib --enable-nls
--without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--disable-werror i486-linux
How-To-Repeat:
Initial source code (5 bugs included: play with -DBUG=x option to
activate them):
--------------------------------
#include <typeinfo>
class BaseB
{
public:
virtual ~BaseB() {}
};
#if BUG == 1
const char* bug1(BaseB const* o)
{
return typeid(typeid(*o)).name();
}
#elif BUG == 2
const std::type_info & bug2(BaseB const* o)
{
return typeid(typeid(*o));
}
#elif BUG == 3
const char* bug3(BaseB * o)
{
return typeid(typeid(*o)).name();
}
#elif BUG == 4
const std::type_info & bug4(BaseB * o)
{
return typeid(typeid(*o));
}
#else
int bug5(BaseB * o)
{
int i;
return (typeid(typeid(*o)) == typeid(i));
}
#endif
--------------------------------
Output from g++ 3.3 -E :
--------------------------------
# 1 "ice-typeid.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "ice-typeid.cc"
# 1 "/usr/include/c++/3.3/typeinfo" 1 3
# 38 "/usr/include/c++/3.3/typeinfo" 3
# 1 "/usr/include/c++/3.3/exception" 1 3
# 40 "/usr/include/c++/3.3/exception" 3
extern "C++" {
namespace std
{
# 52 "/usr/include/c++/3.3/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 "/usr/include/c++/3.3/exception" 3
bool uncaught_exception() throw();
}
namespace __gnu_cxx
{
# 113 "/usr/include/c++/3.3/exception" 3
void __verbose_terminate_handler ();
}
}
# 39 "/usr/include/c++/3.3/typeinfo" 2 3
extern "C++" {
namespace __cxxabiv1
{
class __class_type_info;
}
# 55 "/usr/include/c++/3.3/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 "/usr/include/c++/3.3/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();
};
}
}
# 3 "ice-typeid.cc" 2
class BaseB
{
public:
virtual ~BaseB() {}
};
# 40 "ice-typeid.cc"
int bug5(BaseB * o)
{
int i;
return (typeid(typeid(*o)) == typeid(i));
}
--------------------------------
Output from g++ 3.4 -E :
--------------------------------
# 1 "ice-typeid.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "ice-typeid.cc"
# 1 "/usr/include/c++/3.4/typeinfo" 1 3
# 38 "/usr/include/c++/3.4/typeinfo" 3
# 1 "/usr/include/c++/3.4/exception" 1 3
# 40 "/usr/include/c++/3.4/exception" 3
extern "C++" {
namespace std
{
# 52 "/usr/include/c++/3.4/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 "/usr/include/c++/3.4/exception" 3
bool uncaught_exception() throw();
}
namespace __gnu_cxx
{
# 115 "/usr/include/c++/3.4/exception" 3
void __verbose_terminate_handler ();
}
}
# 39 "/usr/include/c++/3.4/typeinfo" 2 3
extern "C++" {
namespace __cxxabiv1
{
class __class_type_info;
}
# 55 "/usr/include/c++/3.4/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 "/usr/include/c++/3.4/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();
};
}
}
# 3 "ice-typeid.cc" 2
class BaseB
{
public:
virtual ~BaseB() {}
};
# 40 "ice-typeid.cc"
int bug5(BaseB * o)
{
int i;
return (typeid(typeid(*o)) == typeid(i));
}
--------------------------------
Command line:
g++-3.x -c ice-typeid.cc
Optimisation flag seems to have no impact (same problem with
-O3). Likewise for -Wall.
------- Comment #1 from david dot decotigny at poly dot in2p3 dot fr 2006-02-22 13:30 -------
Fix:
It works on more complicated code (?!)... but it's hard to see where
the fix is introduced.
--
Summary: typeid(typeid(*object)) ICE on g++ 3.x / i686
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: david dot decotigny at poly dot in2p3 dot fr
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26417