Bug 7983 - ICE for friend declaration using typedef in class template
Summary: ICE for friend declaration using typedef in class template
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 3.4.0
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: ice-on-invalid-code, monitored
: 6289 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-19 17:16 UTC by Matt Austern
Modified: 2003-08-02 20:51 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-06-23 12:49:34


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Austern 2002-09-19 17:16:01 UTC
The following snippet gives misleading warnings and an ICE:
template<class T> class smart_ptr2 {
    T* real_ptr;
 public:
    typedef typename T::subT  td;
    friend class td;
};

There is a real error in this code: it's illegal to use an elaborated-type-specifier with a typedef name.  (7.1.3, paragraph 4, and 7.1.5.3.)  However, an ICE is not the friendliest diagnostic.

The ICE is in pop_binding.

Release:
2.95 -> 3.4

Environment:
Linux, MacOS X
Comment 1 Kriang Lerdsuwanakij 2002-09-28 07:04:50 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
Comment 2 Andrew Pinski 2003-05-28 14:51:24 UTC
still happens on the mainline (20030525):
(gdb) up 4
#4  0x00016c48 in pop_binding (id=0x83, decl=0x0) at /Volumes/UFS_Partition/pinskia/
src/fsf/gcc/src/gcc/cp/decl.c:1130
1130        abort ();
(gdb) p debug_tree(binding->value)
 <type_decl 0x12ec0e0 td
    type <record_type 0x12e9f50 td type_5 VOID
        align 8 symtab 0 alias set -1
        n_parents 0 use_template=0 interface-unknown
        pointer_to_this <pointer_type 0x12ec070> chain <type_decl 0x12ec0e0 td>>
    decl_2 VOID file pr7983.cc line 6
    align 1 chain <type_decl 0x12e9a80 smart_ptr2<T>>>
$1 = void
(gdb) p *binding
$2 = {
  previous = 0x12e6648, 
  value = 0x12ec0e0, 
  type = 0x0, 
  scope = 0x12e97e0, 
  value_is_inherited = 0, 
  is_local = 1
}
(gdb) l
1125      if (BINDING_VALUE (binding) == decl)
1126        BINDING_VALUE (binding) = NULL_TREE;
1127      else if (BINDING_TYPE (binding) == decl)
1128        BINDING_TYPE (binding) = NULL_TREE;
1129      else
1130        abort ();
1131
1132      if (!BINDING_VALUE (binding) && !BINDING_TYPE (binding))
1133        {
1134          /* We're completely done with the innermost binding for this
(gdb) p debug_tree(decl)

$3 = void
(gdb) p decl
$4 = 0x0
(gdb) bt
#0  0x90005794 in exit ()
#1  0x0018186c in diagnostic_report_diagnostic (context=0x59cffc, diagnostic=
0xbffff410) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/diagnostic.c:1102
#2  0x00181e48 in internal_error (msgid=0x1 <Address 0x1 out of bounds>) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/diagnostic.c:1311
#3  0x00182394 in fancy_abort (file=0x1 <Address 0x1 out of bounds>, line=1577820, 
function=0x44fd3c "pop_binding") at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/
diagnostic.c:1458
#4  0x00016c48 in pop_binding (id=0x83, decl=0x0) at /Volumes/UFS_Partition/pinskia/
src/fsf/gcc/src/gcc/cp/decl.c:1130
#5  0x000184f8 in poplevel_class () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/
gcc/cp/decl.c:1655
#6  0x00092348 in popclass () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/
class.c:5591
#7  0x00091048 in finish_struct (t=0x12e9930, attributes=0x12e99a0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/class.c:5278
#8  0x0010ba40 in finish_class_definition (t=0x580000, attributes=0x559b18, semi=131, 
pop_scope_p=825438208) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/
semantics.c:2033
#9  0x000c9448 in cp_parser_class_specifier (parser=0x12e99a0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/parser.c:11474
#10 0x000c5a2c in cp_parser_type_specifier (parser=0x12e9770, flags=
CP_PARSER_FLAGS_OPTIONAL, is_friend=false, is_declaration=true, 
declares_class_or_enum=0xbffff748, is_cv_qualifier=0xbffff74c) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/parser.c:8469
#11 0x000c3864 in cp_parser_decl_specifier_seq (parser=0x1, flags=19830640, 
attributes=0xbffff7b8, declares_class_or_enum=0xbffff7bc) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc/src/gcc/cp/parser.c:6803
#12 0x000ccc84 in cp_parser_single_declaration (parser=0x0, member_p=
3221223240, friend_p=0x12e9770) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/
gcc/cp/parser.c:13960
#13 0x000ccb4c in cp_parser_template_declaration_after_export (parser=0x12e9770, 
member_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/
parser.c:13903
#14 0x000c3390 in cp_parser_declaration (parser=0x0) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc/src/gcc/cp/parser.c:6405
#15 0x000c3178 in cp_parser_declaration_seq_opt (parser=0x0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/parser.c:6338
#16 0x000be2bc in cp_parser_translation_unit (parser=0x12e9770) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/parser.c:2257
#17 0x000cdd64 in yyparse () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/cp/
parser.c:14668
#18 0x001538a8 in c_common_parse_file (set_yydebug=1) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc/src/gcc/c-opts.c:1644
#19 0x00179f64 in compile_file () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/
toplev.c:2229
#20 0x0017fbfc in do_compile () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc/src/gcc/
toplev.c:5605
#21 0x0017fc88 in toplev_main (argc=14, argv=0xbffffbd8) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc/src/gcc/toplev.c:5651
#22 0x00002398 in _start (argc=14, argv=0xbffffbd8, envp=0xbffffc14) at /SourceCache/
Csu/Csu-45/crt.c:267
#23 0x00002218 in start ()
Comment 3 Kriang Lerdsuwanakij 2003-07-22 13:00:34 UTC
Related to my xref_tag work.
Comment 4 Kriang Lerdsuwanakij 2003-08-01 15:19:07 UTC
Fixed in GCC 3.4 by the patch for PR8442, 8806.
A testcase will be added shortly.
Comment 5 GCC Commits 2003-08-01 15:41:30 UTC
Subject: Bug 7983

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2003-08-01 15:41:27

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: typedef4.C 

Log message:
	PR c++/7983
	* g++.dg/parse/typedef4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2943&r2=1.2944
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/typedef4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 Volker Reichelt 2003-08-02 20:51:37 UTC
*** Bug 6289 has been marked as a duplicate of this bug. ***