[Bug c++/12887] New: ICE when omitting 'typename'

SWElef at post dot sk gcc-bugzilla@gcc.gnu.org
Mon Nov 3 16:11:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12887

           Summary: ICE when omitting 'typename'
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: SWElef at post dot sk
                CC: gcc-bugs at gcc dot gnu dot org

cc1plus.exe stops compiling the code below at line 14 with segmentation fault.

********* error4.cpp BEGIN *********
template <class T>
struct def_ret1{
  typedef T ret;
};

template <typename T>
struct def_ret2{
  typedef typename def_ret1<T>::ret ret;
};

template <class T>
struct ICE{
  typedef def_ret2<T>::ret defT;                     // line 13
  typedef defT::valid valid;                         // line 14
};
********* error3.cpp END *********

Tested compiler versions:

  GNU C++ version 3.3.2 20031007 (prerelease) (i686-pc-cygwin)
          compiled by GNU C version 3.3.1 (cygming special).

  GNU C++ version 3.3.1 (cygming special) (i686-pc-cygwin)
          compiled by GNU C version 3.3.1 (cygming special).

  GNU C++ version 3.2 (mingw special 20020817-1) (mingw32)
          compiled by GNU C version 3.2.

  GNU C++ version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) (i386-redhat-linux)
          compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.3 2.96-110).

  GNU C++ version 2.95.3 20010315 (release) (i686-pc-linux-gnu)
          compiled by GNU C version 2.95.3 20010315 (release).

Relevant c++ output lines:
  error4.cpp:13: warning: `def_ret2<T>::ret' is implicitly a typename
  error4.cpp:13: warning: implicit typename is deprecated, please see the
     documentation for details
  error4.cpp:14: internal compiler error: Segmentation fault

Remark:
  This bug seems to be related to the supposedly solved bug
    http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=65879 ,
    ( Segmentation fault in the absence of 'typename' )
  where there is a comment '3.2 correctly complains'. I tried that code with 3.2
  (mingw), 3.3.1 and 3.3.2 (cygwin) under Win2k and it crashed. (May be the bug
  is fixed for Red Hat distributions.) I hope my code will be a better testcase
  since it contains no include directives.


Additional comments:

  The code is extremely shortened. However, the original line is split to
  lines 13 and 14 for better study of compilers behaviour (c++ wouldn't issue
  the warning otherwise).

  With typename in line 13 the compiler output is
    error4.cpp:14: ISO C++ forbids declaration of `valid' with no type          
(*)
    error4.cpp:14: confused by earlier errors, bailing out
  This suggests that omitting 'typename' in line 13 causes cc1plus.exe to store
  a different information about the identifier 'defT'.

  Remark: With 'typename' in line 14 the program compiles with the warning only.
          With 'typename' in both lines 13 and 14 the program compiles without
          any warning.

          I believe that correct output for error3.cpp should be a warning
          for both lines 13 and 14. With 'typename' in line 13 there should
          be only warning about implicit typenames instead of (*).
          (Severity: ENHANCEMENT - for continued support of implicit typenames)



More information about the Gcc-bugs mailing list