public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14247] New: Problems with templates, ice in write_template_arg_literal
@ 2004-02-22 22:42 schmid at snake dot iap dot physik dot tu-darmstadt dot de
  2004-02-22 23:06 ` [Bug c++/14247] " schwab at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: schmid at snake dot iap dot physik dot tu-darmstadt dot de @ 2004-02-22 22:42 UTC (permalink / raw)
  To: gcc-bugs

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=14247


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/14247] Problems with templates, ice in write_template_arg_literal
  2004-02-22 22:42 [Bug c++/14247] New: Problems with templates, ice in write_template_arg_literal schmid at snake dot iap dot physik dot tu-darmstadt dot de
@ 2004-02-22 23:06 ` schwab at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: schwab at suse dot de @ 2004-02-22 23:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-02-22 23:06 -------
Exact duplicate of 14246. 

*** This bug has been marked as a duplicate of 14246 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-22 23:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-22 22:42 [Bug c++/14247] New: Problems with templates, ice in write_template_arg_literal schmid at snake dot iap dot physik dot tu-darmstadt dot de
2004-02-22 23:06 ` [Bug c++/14247] " schwab at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).