public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15064] New: typeid of template parameter gives ICE
@ 2004-04-22 9:31 gcc-bugzilla at gcc dot gnu dot org
2004-04-22 11:23 ` [Bug c++/15064] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-04-22 9:31 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/15064] [3.4/3.5 Regression] typeid of template parameter gives ICE
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
@ 2004-04-22 11:23 ` pinskia at gcc dot gnu dot org
2004-04-22 15:50 ` giovannibajo at libero dot it
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-22 11:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-04-22 11:17 -------
Confirmed.
Here is the backtrace:
#0 0x080930d1 in tsubst (t=0x40149f30, args=0x0, complain=tf_error, in_decl=0x0)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/pt.c:6733
#1 0x0808b127 in tsubst_copy_and_build (t=0x40149f30, args=0x0, complain=tf_error, in_decl=0x0,
function_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/pt.c:8577
#2 0x0808b970 in tsubst_copy_and_build (t=0x4014d668, args=0x0, complain=tf_error,
in_decl=0x0, function_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/pt.c:8557
#3 0x0808e0d1 in fold_non_dependent_expr (expr=0x4014d668) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/cp/pt.c:3137
#4 0x080e88de in cp_parser_initializer_clause (parser=0x40129900, non_constant_p=0xbffeb9d7)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:11536
#5 0x080f19ef in cp_parser_init_declarator (parser=0x40129900, decl_specifiers=0x4014d5dc,
prefix_attributes=0x0,
function_definition_allowed_p=false, member_p=false, declares_class_or_enum=0,
function_definition_p=0xbffeba07)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:11488
#6 0x080f1b04 in cp_parser_simple_declaration (parser=0x40129900,
function_definition_allowed_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:6566
#7 0x080f1c78 in cp_parser_block_declaration (parser=0x40129900, statement_p=true)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:6482
#8 0x080ec45f in cp_parser_statement (parser=0x40129900, in_statement_expr_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:6190
#9 0x080ecadb in cp_parser_compound_statement (parser=0x40129900, in_statement_expr_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:5732
#10 0x080f1160 in cp_parser_ctor_initializer_opt_and_function_body (parser=0x40129900)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:11428
#11 0x080f14a8 in cp_parser_function_definition_after_declarator (parser=0x40129900,
inline_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:14301
#12 0x080f187a in cp_parser_init_declarator (parser=0x40129900, decl_specifiers=0x4014d550,
prefix_attributes=0x0,
function_definition_allowed_p=true, member_p=false, declares_class_or_enum=0,
function_definition_p=0xbffebb83)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:14246
#13 0x080f240c in cp_parser_single_declaration (parser=0x40129900, member_p=false,
friend_p=0xbffebbbb)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:14459
#14 0x080e8fa1 in cp_parser_template_declaration_after_export (parser=0x40129900,
member_p=false)
at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:14365
#15 0x080f296e in cp_parser_declaration (parser=0x40129900) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/cp/parser.c:6378
#16 0x080f2b0f in cp_parser_declaration_seq_opt (parser=0x40129900) at /home/gates/pinskia/src/
gnu/gcc/src/gcc/cp/parser.c:6300
#17 0x080f2cfe in c_parse_file () at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:2393
#18 0x08180e6b in c_common_parse_file (set_yydebug=0) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/c-opts.c:1238
#19 0x083bd8de in toplev_main (argc=0, argv=0xbffebd54) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/toplev.c:1596
#20 0x08184a3e in main (argc=0, argv=0x0) at /home/gates/pinskia/src/gnu/gcc/src/gcc/main.c:35
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |ice-on-valid-code
Known to fail| |3.4.0 3.5.0
Known to work| |3.3.3
Last reconfirmed|0000-00-00 00:00:00 |2004-04-22 11:17:59
date| |
Summary|typeid of template parameter|[3.4/3.5 Regression] typeid
|gives ICE |of template parameter gives
| |ICE
Target Milestone|--- |3.4.1
Version|3.4 |3.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/15064] [3.4/3.5 Regression] typeid of template parameter gives ICE
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
2004-04-22 11:23 ` [Bug c++/15064] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-04-22 15:50 ` giovannibajo at libero dot it
2004-04-22 17:07 ` giovannibajo at libero dot it
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-22 15:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-04-22 15:30 -------
Another fallout of my patch to fold initializers in templates.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |giovannibajo at libero dot
|dot org |it
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/15064] [3.4/3.5 Regression] typeid of template parameter gives ICE
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
2004-04-22 11:23 ` [Bug c++/15064] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-04-22 15:50 ` giovannibajo at libero dot it
@ 2004-04-22 17:07 ` giovannibajo at libero dot it
2004-04-23 13:07 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-22 17:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-04-22 17:00 -------
Patch posted here:
http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01482.html
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/15064] [3.4/3.5 Regression] typeid of template parameter gives ICE
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-04-22 17:07 ` giovannibajo at libero dot it
@ 2004-04-23 13:07 ` cvs-commit at gcc dot gnu dot org
2004-04-23 13:11 ` cvs-commit at gcc dot gnu dot org
2004-04-23 13:15 ` giovannibajo at libero dot it
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-04-23 13:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-04-23 12:57 -------
Subject: Bug 15064
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: giovannibajo@gcc.gnu.org 2004-04-23 12:57:19
Modified files:
gcc/cp : ChangeLog parser.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/template: crash18.C
Log message:
PR c++/15064
* parser.c (cp_parser_postfix_expression): typeid operator cannot be
used in integral constant expressions.
PR c++/15064
* g++.dg/template/crash18.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4038&r2=1.4039
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.190&r2=1.191
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3697&r2=1.3698
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash18.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/15064] [3.4/3.5 Regression] typeid of template parameter gives ICE
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-04-23 13:07 ` cvs-commit at gcc dot gnu dot org
@ 2004-04-23 13:11 ` cvs-commit at gcc dot gnu dot org
2004-04-23 13:15 ` giovannibajo at libero dot it
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-04-23 13:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-04-23 13:00 -------
Subject: Bug 15064
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: giovannibajo@gcc.gnu.org 2004-04-23 13:00:13
Modified files:
gcc/cp : ChangeLog parser.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/template: crash18.C
Log message:
PR c++/15064
* parser.c (cp_parser_postfix_expression): typeid operator cannot be
used in integral constant expressions.
PR c++/15064
* g++.dg/template/crash18.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.99&r2=1.3892.2.100
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.25&r2=1.157.2.26
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.171&r2=1.3389.2.172
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash18.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/15064] [3.4/3.5 Regression] typeid of template parameter gives ICE
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-04-23 13:11 ` cvs-commit at gcc dot gnu dot org
@ 2004-04-23 13:15 ` giovannibajo at libero dot it
5 siblings, 0 replies; 7+ messages in thread
From: giovannibajo at libero dot it @ 2004-04-23 13:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-04-23 13:05 -------
Fixed in 3.4.1 and mainline. Thank you for your report!
As for a temporary workaround, the problem comes from the use of typeid()
within an initializer expression of a variable in a template. Try using a
wrapper function, something along the lines of:
template <class T>
const std::type_info& wrapper_typeid()
{ return typeid(T); }
/* ... */
template <class T>
void dummy() {
const std::type_info& tid = wrapper_typeid<T>();
}
Untested, but should work as a workaround.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15064
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-04-23 13:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-22 9:31 [Bug c++/15064] New: typeid of template parameter gives ICE gcc-bugzilla at gcc dot gnu dot org
2004-04-22 11:23 ` [Bug c++/15064] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-04-22 15:50 ` giovannibajo at libero dot it
2004-04-22 17:07 ` giovannibajo at libero dot it
2004-04-23 13:07 ` cvs-commit at gcc dot gnu dot org
2004-04-23 13:11 ` cvs-commit at gcc dot gnu dot org
2004-04-23 13:15 ` giovannibajo at libero dot it
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).