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++/13339] New: ICE with some template code


This testcase gives me following error. If I uncomment the other line in foo()
and comment the first then I get the second error that I think I should get
since afaik the compiler is supposed to be able to deduce the types of the
parameters, isn't it?

The ICE:
logout ~/TIS>g++ -c join-testcase.ii
join-testcase.cxx: In instantiation of `join_into_stream<__gnu_norm::list<int,
std::allocator<int> >, char*>':
join-testcase.cxx:39:   instantiated from here
join-testcase.cxx:20: error: `char*' is not a class, struct, or union type
join-testcase.cxx:20: internal compiler error: tree check: expected class 'd',
have 'x' (error_mark) in tsubst_friend_function, at cp/pt.c:4911
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

The other error:
logout ~/TIS>g++ -c join-testcase.cxx
join-testcase.cxx: In function `void foo(std::ostream&, __gnu_norm::list<int,
std::allocator<int> >&)':
join-testcase.cxx:40: error: missing template arguments

The GCC is configured like this:
logout ~/TIS>g++ -v
Reading specs from /home/4/wilx/lib/gcc/i386-unknown-freebsd4.9/3.4/specs
Configured with: ../srcdir/configure --disable-nls
--enable-version-specific-runtime-libs --enable-dwarf2 --with-cpu=i686
--with-arch=i686 --with-system-zlib --disable-shared --prefix=/home/4/wilx
--enable-languages=c,c++ --with-gc=zone --disable-sjlj-exceptions
Thread model: posix
gcc version 3.4 20031130 (experimental)


----8<-----
#include <list>
#include <ios>
#include <iostream>

template <typename _Seq, typename _Res>
class join_into_stream
{
  const _Seq & m_seq;
  const _Res m_sep;

public:
  join_into_stream (const _Seq & seq, _Res sep)
    : m_seq (seq), m_sep (sep)
  { }

  friend 
  std::basic_ostream<typename _Res::value_type> & 
  operator << (std::basic_ostream<typename _Res::value_type> & os,
               const join_into_stream & jism)
  {
    typename _Seq::const_iterator it = jism.m_seq.begin ();
    typename _Seq::const_iterator next = it;
    ++next;
    for (; 
         next != jism.m_seq.end ();
         ++it, ++next) 
      os << *it << jism.m_sep;
    
    os << *it;
    
    return os;
  }
};


void 
foo (std::ostream & out, std::list<int> & l)
{
  out << join_into_stream<std::list<int>, char *> (l, " ");
  //out << join_into_stream (l, " ");
}
----8<-----

-- 
           Summary: ICE with some template code
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: v dot haisman at sh dot cvut dot cz
                CC: gcc-bugs at gcc dot gnu dot org,v dot haisman at sh dot
                    cvut dot cz
 GCC build triplet: i386-unknown-freebsd4.9
  GCC host triplet: i386-unknown-freebsd4.9
GCC target triplet: i386-unknown-freebsd4.9


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


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