This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14246] New: Problems with templates, ice in write_template_arg_literal
- From: "schmid at snake dot iap dot physik dot tu-darmstadt dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Feb 2004 22:40:53 -0000
- Subject: [Bug c++/14246] New: Problems with templates, ice in write_template_arg_literal
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The followimg file, stripped down from the file types/types.C from the book C++
Template - The Complete Guide by David Vandevoorde and Nicolai M. Josuttis,
causes an ice. It used to work with earlier versions of gcc 3.4. Gcc 3.3 has no
problems compiling this imho valid source code.
source code d.C
template <typename T>
class IsFundaT {
public:
enum { Yes = 0, No = 1};
};
template<> class IsFundaT<void> { public: enum { Yes = 1, No = 0 }; };
template<> class IsFundaT<bool> { public: enum { Yes = 1, No = 0 }; };
template<> class IsFundaT<signed int> { public: enum { Yes = 1, No = 0 }; };
template<> class IsFundaT<unsigned int> { public: enum { Yes = 1, No = 0 }; };
template<typename T>
class IsFunctionT {
private:
typedef char One;
typedef struct { char a[2]; } Two;
template<typename U> static One test(...);
template<typename U> static Two test(U (*)[1]);
public:
enum { Yes = sizeof(IsFunctionT<T>::template test<T>(0)) == 1 };
enum { No = !Yes };
};
template<typename T>
class CompoundT {
public:
enum { IsPtrT = 0, IsRefT = 0, IsArrayT = 0,
IsFuncT = IsFunctionT<T>::Yes,
IsPtrMemT = 0 };
typedef T BaseT;
typedef T BottomT;
typedef CompoundT<void> ClassT;
};
struct SizeOverOne { char c[2]; };
template<typename T,
bool convert_possible = !CompoundT<T>::IsFuncT>
class ConsumeUDC {
public:
operator T() const;
};
template <typename T>
class ConsumeUDC<T, false> {
};
template <bool convert_possible>
class ConsumeUDC<void, convert_possible> {
};
char enum_check(bool);
char enum_check(signed int);
char enum_check(unsigned int);
SizeOverOne enum_check(...);
template<typename T>
class IsEnumT {
public:
enum { Yes = IsFundaT<T>::No &&
sizeof(enum_check(ConsumeUDC<T>()))==1 };
enum { No = !Yes };
};
template <typename T>
class TypeT {
public:
enum { IsFundaT = IsFundaT<T>::Yes,
IsEnumT = IsEnumT<T>::Yes } ;
};
template <typename T>
void check()
{
if (TypeT<T>::IsFundaT) { return 1;}
}
int main()
{
check<int>();
}
g++ -W -Wall d.C -v
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc/configure --enable-threads=posix
--enable-languages=c,c++,f77,objc --enable-__cxa_atexit --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.0 20040221 (prerelease)
/usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -quiet -v -D_GNU_SOURCE
d.C -quiet -dumpbase d.C -mtune=pentiumpro -auxbase d -W -Wall -version -o
/tmp/ccSfyb76.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
/usr/local/include
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/include
/usr/include
End of search list.
GNU C++ version 3.4.0 20040221 (prerelease) (i686-pc-linux-gnu)
compiled by GNU C version 3.4.0 20040221 (prerelease).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64274
d.C: In instantiation of `IsEnumT<int>':
d.C:72: instantiated from `TypeT<int>'
d.C:79: instantiated from `void check() [with T = int]'
d.C:85: instantiated from here
d.C:63: internal compiler error: in write_template_arg_literal, at cp/mangle.c:2125
Please submit a full bug report,
with preprocessed source if appropriate.
--
Summary: Problems with templates, ice in
write_template_arg_literal
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P1
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: schmid at snake dot iap dot physik dot tu-darmstadt dot
de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14246
- Follow-Ups:
- [Bug c++/14246] Problems with templates, ice in write_template_arg_literal
- From: schwab at suse dot de
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: pinskia at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: giovannibajo at libero dot it
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: pinskia at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: s_gccbugzilla at nedprod dot com
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: pinskia at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: s_gccbugzilla at nedprod dot com
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: pinskia at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: pinskia at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: giovannibajo at libero dot it
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: reichelt at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: giovannibajo at libero dot it
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: giovannibajo at libero dot it
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: cvs-commit at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: cvs-commit at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: cvs-commit at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: cvs-commit at gcc dot gnu dot org
- [Bug c++/14246] [3.4/3.5 Regression] Problems with templates, ice in write_template_arg_literal
- From: giovannibajo at libero dot it