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]

c++/pt.c mixing-up inner/outer template args


-------------------
cat main.cpp

  namespace
Gcsp
  {
      enum
    OffRoot
      { OffYes
      , OffNo
      , Root
      };
  }
  ;//end Gcsp namespace
//=================================
template
  < template<typename ST,Gcsp::OffRoot GF>class SUBJECT
  , typename SUBJ_TOP
  , Gcsp::OffRoot GCSP_OFFROOT=Gcsp::Root
  >
  class
ProxOwnBtm
  {}
  ;
//=================================
template<typename TYPE>
  class
SubjProxAlloc_T
  {}
  ;
//=================================
template
  < typename TYPE
  >
  class
my_vector
  {
  }
  ;//end my_vector class
//=================================
template
  < template<typename,Gcsp::OffRoot>class SUBJ_ELEM
  , typename TOP_ELEM
  , template<typename,Gcsp::OffRoot>class SUBJ_CONT
  >
  class
SubjProxOwnVec
  {
  public:
    template< Gcsp::OffRoot OR>
      struct
    Curry
      {   typedef
        ProxOwnBtm<SUBJ_ELEM,TOP_ELEM,OR>
      E
        ;
      }
      ;
    template
      < typename TOP_CONT
      , Gcsp::OffRoot OR_CONT=Gcsp::Root
      >
      class
    ContElem
      : public SUBJ_CONT<TOP_CONT,OR_CONT>
      , public my_vector
          < typename Curry<OR_CONT>::E
          >
      {
      }
      ;//end ContElem class
  }
  ;//end SubjProxOwnVec class
//=================================
template
  < typename SUBJ_TOP
  , Gcsp::OffRoot GCSP_OFFROOT=Gcsp::Root
  >
  class
SubjOffRoot
  {
  }
  ;//end SubjOffRoot class
//=================================
template
  < typename SUBJ_TOP
  , Gcsp::OffRoot GCSP_OFFROOT=Gcsp::Root
  >
  class
VertexLetter
  {
  }
  ;//end VertexLetter class
//=================================
template
  < typename SUBJ_TOP
  , Gcsp::OffRoot GCSP_OFFROOT=Gcsp::Root
  >
  class
VertexWord
  {
  public:
        typedef
      SubjProxOwnVec<VertexLetter, SUBJ_TOP, SubjOffRoot>
    SubjProxVecType
      ;
        typedef
      SubjProxVecType::ContElem<SUBJ_TOP, GCSP_OFFROOT>
    SubjStateType
      ;
  }
  ;//end VertexWord class
//=================================
  class
SubjTop_test
  {
  }
  ;//end SubjTop_test class
//=================================
  VertexWord<SubjTop_test>
w
  ;

-------------------
/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/install/bin/g++ -c   main.cpp

:arg not a TYPE_P=
 <integer_cst 0x2ac0a860 type <enumeral_type 0x2ac0b780 OffRoot> constant 2>
t=
 <template_type_parm 0x2ac10e00 TOP_ELEM VOID
    align 8 symtab 0 alias set 0
   index 1 level 1 orig_level 1
    chain <type_decl 0x2ac10e80 TOP_ELEM>>
levels=1, level=1, veclen=2
arg[0]=
 <record_type 0x2ac17c80 SubjTop_test type_1 type_5 QI
    size <integer_cst 0x2abf5400 type <integer_type 0x2abfa380 bit_size_type> constant 8>
    unit size <integer_cst 0x2abf5f00 type <integer_type 0x2abfa300 unsigned int> constant 1>
    user align 8 symtab 0 alias set -1
    fields <type_decl 0x2ac17e00 SubjTop_test type <record_type 0x2ac17c80 SubjTop_test>
        nonlocal VOID file main.cpp line 114
        align 1 context <record_type 0x2ac17c80 SubjTop_test>
       >
    X() X(constX&) this=(X&) n_parents 0 use_template=0 interface-unknown vtable-needs-writing
    member-functions <tree_vec 0x2ac19600
        elt 0 <overload 0x2ac0e750>
        elt 2 <function_decl 0x2ac1a680 operator=>
        elt 3 <overload 0x2ac0e7d0>
        elt 4 <overload 0x2ac0e7a0>>
    pointer_to_this <pointer_type 0x2ac17d00> reference_to_this <reference_type 0x2ac1a480> chain <type_decl 0x2ac17d80 SubjTop_test>>
arg[1]=
 <integer_cst 0x2ac0a860 type <enumeral_type 0x2ac0b780 OffRoot> constant 2>
main.cpp: In instantiation of `VertexWord<SubjTop_test, Root>':
main.cpp:120:   instantiated from here
main.cpp:108: Internal compiler error in tsubst, at cp/pt.c:6329
Please submit a full bug report.
 See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
make: *** [compile] Error 1
uname -a
Linux localhost.localdomain 2.2.13-4mdk #1 Tue Sep 7 18:23:11 CEST 1999 i586 unknown
/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/install/bin/g++ -v
Reading specs from /mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/install/lib/gcc-lib/i586-pc-linux-gnu/2.97/specs
Configured with:  --prefix=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/install --with-local-prefix=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/local --with-gxx-include-dir=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/local/g++ --enable-languages=c++ --enable-checking --enable-debug --enable-libgcc-rebuild=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/build : (reconfigured)  : (reconfigured) /mnt/scratch/gcc-2.96/latest-cvs/gcc/configure --prefix=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/install --with-local-prefix=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/local --with-gxx-include-dir=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/local/g++ --enable-languages=c++ --enable-checking --enable-debug --enable-libgcc-rebuild=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/build : (reconfigured)  : (reconfigured) /mnt/scratch/gcc-2.96/latest-cvs/gcc/configure --prefix=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/install
--with-local-prefix=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/local --with-gxx-include-dir=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/local/g++ --enable-languages=c++ --enable-checking --enable-debug --enable-libgcc-rebuild=/mnt/scratch/gcc-2.96/latest-cvs/bug417-patch/build : (reconfigured)
gcc version 2.97 20001218 (experimental)
-------------------
Apparently, the cc1plus is mixing the args to outter template with
those to inner template.  gdb of cc1plus shows the backtrace:

(gdb) bt
#0  fancy_abort (
    file=0x830b160 "/mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c",
    line=6329, function=0x830ce38 "tsubst")
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/diagnostic.c:1722
#1  0x809830c in store_init_value (decl=0x0, init=0x830b160)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/typeck2.c:270
#2  0x808c947 in tsubst (t=0x2ac10e80, args=0x2ac18b00, complain=1,
    in_decl=0x0) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:6329
#3  0x808f61d in tsubst_copy (t=0x2ac10e80, args=0x2ac18b00, complain=1,
    in_decl=0x0) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:7110
#4  0x8090f59 in tsubst_expr (t=0x2ac10e80, args=0x2ac18b00, complain=1,
    in_decl=0x0) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:7445
#5  0x8088c3e in tsubst_template_arg_vector (t=0x2ac183c0, args=0x2ac18b00,
    complain=1) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:5246
#6  0x8089330 in tsubst_aggr_type (t=0x2ac17900, args=0x2ac18b00, complain=1,
    in_decl=0x0, entering_scope=1)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:5369
#7  0x808923d in tsubst_aggr_type (t=0x2ac17a80, args=0x2ac18b00, complain=1,
    in_decl=0x0, entering_scope=0)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:5354
#8  0x808c3fe in tsubst (t=0x2ac17a80, args=0x2ac18b00, complain=1,
    in_decl=0x0) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:6193
#9  0x808c395 in tsubst (t=0x2ac17c00, args=0x2ac18b00, complain=1,
    in_decl=0x0) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:6181
#10 0x8088398 in instantiate_class_template (type=0x2ac1a880)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:5040
#11 0x80d518b in complete_type (type=0x2ac1a880)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/typeck.c:158
#12 0x80664b3 in start_decl_1 (decl=0x2ac1aa80)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/decl.c:7358
#13 0x80661a8 in start_decl (declarator=0x2ac19440, declspecs=0x2ac18c00,
    initialized=0, attributes=0x0, prefix_attributes=0x0)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/decl.c:7298
#14 0x80c60df in parse_decl (declarator=0x2ac19440, attributes=0x0,
    initialized=0) at parse.y:138
#15 0x80c6115 in parse_decl0 (declarator=0x2ac19440, specs_attrs=0x2ac18c00,
    lookups=0x0, attributes=0x0, initialized=0) at parse.y:148
#16 0x80c93a1 in yyparse_1 () at parse.y:2041
#17 0x812ada6 in yyparse ()
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/c-lex.c:144
#18 0x8130ba9 in compile_file (name=0x7ffffd24 "main.cpp")
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/toplev.c:2373
#19 0x8134c00 in main (argc=3, argv=0x7ffffbc4)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/toplev.c:4857

after gdb up 5:

(gdb) up 5
#5  0x8088c3e in tsubst_template_arg_vector (t=0x2ac183c0, args=0x2ac18b00,
    complain=1) at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:5246
(gdb) cal debug_tree(t)
 <tree_vec 0x2ac183c0
    elt 0 <template_template_parm 0x2ac10e00>
    elt 1 <template_type_parm 0x2ac10e80 TOP_ELEM>
    elt 2 <template_template_parm 0x2ac12280>>
(gdb) up 1
#6  0x8089330 in tsubst_aggr_type (t=0x2ac17900, args=0x2ac18b00, complain=1,
    in_decl=0x0, entering_scope=1)
    at /mnt/scratch/gcc-2.96/latest-cvs/gcc/gcc/cp/pt.c:5369
(gdb) cal debug_tree(t)
 <record_type 0x2ac17900 SubjProxOwnVec<SUBJ_ELEM,TOP_ELEM,SUBJ_CONT> type_5 VOID
    align 8 symtab 0 alias set -1
    n_parents 0 use_template=1 interface-unknown
    pointer_to_this <pointer_type 0x2ac17980> chain <type_decl 0x2ac17a00 SubjProxOwnVec<SUBJ_ELEM,TOP_ELEM,SUBJ_CONT>>>
(gdb) cal debug_tree(args)
 <tree_vec 0x2ac18b00
    elt 0 <record_type 0x2ac17d00 SubjTop_test>
    elt 1 <integer_cst 0x2ac09860 2>>
(gdb)

So the problem is apparent in the args to tsubst_aggr_type where t
requires 3 args but args has only 2.
-------------------



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