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]

c++:ICE with -g on template specialization of nested class, a kinda template typedef

[Get raw message]

cd /home/evansl/prog_dev/boost/dev/lib/gc_sel_ssp/tests/compiler_tests/gcc_bugs/gen_prox_tmpl/
make bugreport
-------------------
The -g compiler option results in ICE; however, without it, the error
messages:

/mnt/scratch/download/gcc-cvs/debug/install/bin/g++ -c  main.cpp -o main.o
main.cpp: In function `int main()':
main.cpp:205: cannot convert `typename gen_prox_tmpl<SubjType*, SubjCollect, 
   OffRoot>::gen_subj_tmpl<off_no>::my_type*' to `float*' in initialization
main.cpp:206: cannot convert `typename gen_prox_tmpl<SubjType*, SubjCollect, 
   OffRoot>::gen_subj_tmpl<off_no>::my_type*' to `float*' in initialization

are wrong.  This is because the following lines:

      ; float x=0.9
      ; {
        ; subj_type s=&x
        ; subj_type1 s1=&x
        ;}

compile without error, and:

    ; typedef gen_prox_tmpl<subj_type,yes_collect,offroot>::gen_subj_tmpl<offroot>::my_type* subj_type1
-------------------
uname -a
Linux localhost.localdomain 2.2.13-4mdk #1 Tue Sep 7 18:23:11 CEST 1999 i586 unknown
/mnt/scratch/download/gcc-cvs/debug/install/bin/g++ -v
Reading specs from /mnt/scratch/download/gcc-cvs/debug/install/lib/gcc-lib/i586-pc-linux-gnu/3.1/specs
Configured with: /mnt/scratch/download/gcc-cvs/gcc/configure --prefix=/mnt/scratch/download/gcc-cvs/debug/install --enable-languages=c++ --enable-checking --enable-threads=posix : (reconfigured) /mnt/scratch/download/gcc-cvs/gcc/configure --prefix=/mnt/scratch/download/gcc-cvs/debug/install --enable-languages=c++ --enable-checking --enable-threads=posix
Thread model: posix
gcc version 3.1 20011114 (experimental)
-------------------
cat main.cpp
#include <vector>
using namespace std;
//----------------
enum off_root
  { off_yes
  , off_no
  }
  ;
//----------------
template
  < template<off_root>class SubjTmpl
  , typename SubjCollect
  , off_root OffRoot
  >
class gc_prox
  ;
//----------------
struct no_collect
  {};
struct yes_collect
  {};
//----------------
  struct
prox_void
  {
        typedef
      void
    subj_type
      ;
      subj_type*
    m_subj
      ;
        static
      prox_void*
    c_prox
      ;
    prox_void(subj_type*a_subj=0)
      : m_subj(a_subj)
      {}
  }
  ;//exit prox_void struct
//----------------
template
  < off_root OffRoot
  >
  class
prox_offset_record
  //Purpose:
  //  Dummy class for OffRoot != off_yes
  {
  protected:
    prox_offset_record
      ( prox_void*
      )
      {
      ;}
  };//end prox_offset_record class
template
  <
  >
  class
prox_offset_record
  < off_yes
  >
  //Purpose:
  //  record offset of CTOR arg from
  //  start of containing subject
  //  into a vector of offsets for 
  //  the containing subject's class.
  {
  protected:
    prox_offset_record
      ( prox_void*a_p
      )
      { prox_void::c_prox=a_p 
      ;}
  };//end prox_offset_record class
//----------------
template
  < template<off_root>class SubjTmpl
  , typename SubjCollect
  , off_root OffRoot
  >
struct gc_prox
  : private prox_void
  , private prox_offset_record<OffRoot>
  {
        typedef
      typename SubjTmpl<off_no>::my_type
    subj_type
      ;
        typedef
      SubjCollect
    collect_type
      ;
        typedef
      gc_prox<SubjTmpl,collect_type,OffRoot>
    my_type
      ;
    gc_prox(subj_type*a_subj=0)
      : prox_void(a_subj)
      , prox_offset_record<OffRoot>(this)
      {}
    gc_prox(my_type const&a_prox)
      : prox_void(a_prox)
      , prox_offset_record<OffRoot>(this)
      {}
      subj_type*
    get_subj(void)const
      { return static_cast<subj_type*>(m_subj)
      ;}
      my_type const&
    operator=(subj_type*a_subj)
      { m_subj=a_subj
      ; return *this
      ;}
      my_type const&
    operator=(my_type const &a_prox)
      { m_subj=a_prox.m_subj
      ; return *this
      ;}
  }
  ;//end gc_prox class
//----------------
template
  < typename SubjType
  , typename SubjCollect
  , off_root OffRoot
  >
struct gen_prox_tmpl
  {
    typedef SubjType prox_type;
  };
template
  < typename SubjType
  , off_root OffRoot
  >
struct gen_prox_tmpl
  < SubjType
  , no_collect
  , OffRoot
  >
  {
    typedef SubjType prox_type;
  };
template
  < typename SubjType
  , typename SubjCollect
  , off_root OffRoot
  >
struct gen_prox_tmpl
  < SubjType*
  , SubjCollect
  , OffRoot
  >
  {
     template
       < off_root OR
       >
     struct gen_subj_tmpl
       {
         typedef SubjType my_type;
       };
     typedef gc_prox<gen_subj_tmpl,SubjCollect,OffRoot> prox_type;
  };
template
  < typename SubjType
  , off_root OffRoot
  >
struct gen_prox_tmpl
  < SubjType*
  , no_collect
  , OffRoot
  >
  {
    typedef SubjType* prox_type;
  };
//----------------
//----------------
  int
main(void)
  { 
  ; { 
    ; off_root const offroot=off_no
    ; typedef float subj_type;
    ; typedef gen_prox_tmpl<subj_type,yes_collect,offroot>::prox_type prox_type
    ; prox_type p=9.9
    ; subj_type s=p
    ;}
  ; { 
    ; typedef float* subj_type;
    ; off_root const offroot=off_no
    ; typedef gen_prox_tmpl<subj_type,yes_collect,offroot>::gen_subj_tmpl<offroot>::my_type* subj_type1
    ; typedef gen_prox_tmpl<subj_type,yes_collect,offroot>::prox_type prox_type
    ; {
      ; float x=0.9
      ; {
        ; subj_type s=&x
        ; subj_type1 s1=&x
        ;}
      ;}
    ; {
      ; gen_prox_tmpl<subj_type,yes_collect,offroot>::prox_type p
      ; subj_type s=p.get_subj()
      ; subj_type1 s1=p.get_subj()
      ;}
    ;}
  ; return 0
  ;}
-------------------
/mnt/scratch/download/gcc-cvs/debug/install/bin/g++ -c  main.cpp -o main.o
main.cpp: In function `int main()':
main.cpp:205: cannot convert `typename gen_prox_tmpl<SubjType*, SubjCollect, 
   OffRoot>::gen_subj_tmpl<off_no>::my_type*' to `float*' in initialization
main.cpp:206: cannot convert `typename gen_prox_tmpl<SubjType*, SubjCollect, 
   OffRoot>::gen_subj_tmpl<off_no>::my_type*' to `float*' in initialization
make: *** [main.o] Error 1

Compilation exited abnormally with code 2 at Sat Nov 17 20:49:13

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