Bug 9464 - [3.4 regression] ICE on missing typename
Summary: [3.4 regression] ICE on missing typename
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2003-01-27 19:56 UTC by Jeffrey D. Oldham
Modified: 2004-07-17 01:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
goo.ii (37.98 KB, text/x-c++)
2003-05-21 15:17 UTC, Jeffrey D. Oldham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey D. Oldham 2003-01-27 19:56:00 UTC
ICE on code that is missing a 'typename'.  Inclding the 'typename' obviates the problem.

The program is small:

// Compiling this program causes an internal_compilation_error.  The
// program is missing a 'typename'.  Compiling with '-DAVOID_ERROR'
// causes the missing 'typename' to be included and the compilation
// succeeds.

#include <vector>

template<class T>
struct CreateLeaf {};

template<class T>
struct CreateLeaf<std::vector<T> >
{
#ifdef AVOID_ERROR
  typedef typename std::vector<T>::const_iterator Leaf_t;
#else // erroneous
  typedef std::vector<T>::const_iterator Leaf_t;
#endif // AVOID_ERROR
};

Release:
head

Environment:
Red Hat Linux release 7.2 (Enigma)
i686-pc-linux-gnu)

How-To-Repeat:
/home/oldham/gcc-install/gcc1/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -fpreprocessed goo.ii -quiet -dumpbase goo.C -auxbase goo -Wall -pedantic -version -o goo.s
Comment 1 Wolfgang Bangerth 2003-01-27 22:00:59 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Fallout from the implicit typename deprecation.
    Here's a similar snippet, which I think is even legal since
    we don't instantiate for a particular value of T (well, legal except for the missing typename, of course):
    -----------------------------------
    template<typename T, typename A> struct X {
        typedef typename A::template foo<T>::type type;
    };
    
    template<typename T, typename = int> struct Y {
        typedef double type;
        typename X<T,T>::type t;
    };
    
    template<class T>
    struct Z {
        typedef Y<T>::type type;
    };
    -------------------------
    
    g/a> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.ii
    x.ii: In instantiation of `Y<T, int>':
    x.ii:12:   instantiated from here
    x.ii:7: error: `Y<T, <anonymous template type parameter> >::t' has incomplete
       type
    x.ii:7: internal compiler error: in cxx_incomplete_type_diagnostic, at
       cp/typeck2.c:278
    Please submit a full bug report,
    with preprocessed source if appropriate.
    
    
    Since an ICE is worse than an error message, I rate this
    as a regression. It gave warnings about the implicit
    typename stuff with 3.3 and 3.2.2, and worked with 2.95
    
    W.
Comment 2 Andrew Pinski 2003-05-28 15:51:32 UTC
Fixed on the mainline (20030525), already (in fact this might be a duplicate):

[omni:~/src/gccPRs] pinskia% /Volumes/UFS_Partition/pinskia/fsf/bin/g++ pr9464.cc
pr9464.cc:13: error: type `Y<T, int>' is not derived from type `Z<T>'
pr9464.cc:13: error: ISO C++ forbids declaration of `type' with no type
pr9464.cc:13: error: expected `;'