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]

[Bug c++/30721] New: ICE on invalid template code


Attached test case ICEs. The code is AFAIK invalid:

-------8<-------

#include <stdio.h>

template <typename Numeric>
class Table
{
  typedef struct
  {
    const char * const name;
    Numeric index;
  } Tableitem;

  static const Tableitem entries[];

public:
  const char * const
  operator[] (Numeric Tableindex)
  {
    for (int i=0; i<sizeof(entries)/sizeof(Tableitem); ++i)
      if(entries[i].index==Tableindex)
        return entries[i].name;
    return 0;
  }
};


enum funky { feeling, lost, somewhere, in, space };

template<funky>
const Table<funky>::Tableitem Table<funky>::entries[] =
  {
    {"feeling", feeling},
    {"lost", lost},
    {"somewhere", somewhere},
    {"in", in},
    {"space", space},
  };

int main (int argc, char **argv)
{
  Table<funky> FunkyTable;
  printf("Funkytable somewhere=[%s]\n", FunkyTable[somewhere]);
  return 0;
}

-------8<-------

The error:

logout::wilx:~/tmp> g++42 -o ice ice.cxx
ice.cxx:14: internal compiler error: in import_export_decl, at cp/decl2.c:1956
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

GCC version:

logout::wilx:~/tmp> g++42 -v
Using built-in specs.
Target: i386-portbld-freebsd6.2
Configured with: ./..//gcc-4.2-20070117/configure --disable-nls
--with-system-zlib --with-libiconv-prefix=/usr/local --with-gmp=/usr/local
--program-suffix=42 --libdir=/usr/local/lib/gcc-4.2.0
--with-gxx-include-dir=/usr/local/lib/gcc-4.2.0/include/c++/
--infodir=/usr/local/info/gcc42 --disable-rpath --prefix=/usr/local
i386-portbld-freebsd6.2
Thread model: posix
gcc version 4.2.0 20070117 (prerelease)


-- 
           Summary: ICE on invalid template code
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: v dot haisman at sh dot cvut dot cz
 GCC build triplet: i386-portbld-freebsd6.2
  GCC host triplet: i386-portbld-freebsd6.2
GCC target triplet: i386-portbld-freebsd6.2


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


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