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]

Internal compiler error.


Linux jonas 2.0.32 #19 Mon Dec 15 01:07:50 EST 1997 i586 unknown

Reading specs from /usr/lib/gcc-lib/i386-linux/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)

In file included from /usr/include/g++/stl_algobase.h:82,
                 from /usr/include/g++/algorithm:30,
                 from twincpp.cc:3:
/usr/include/g++/stl_iterator.h:528: warning: friend declaration `bool operator ==(const class reverse_bidirectional_iterator<BidirectionalIterator,T,Reference,Distance> &, const class reverse_bidirectional_iterator<BidirectionalIterator,T,Reference,Distance> &)'
/usr/include/g++/stl_iterator.h:528: warning:   will not be treated as a template instantiation
/usr/include/g++/stl_iterator.h:528: warning:   unless you compile with -fguiding-decls
/usr/include/g++/stl_iterator.h:528: warning:   or add <> after the function name
/usr/include/g++/stl_iterator.h:857: warning: friend declaration `bool operator ==(const class istream_iterator<T,Distance> &, const class istream_iterator<T,Distance> &)'
/usr/include/g++/stl_iterator.h:857: warning:   will not be treated as a template instantiation
In file included from /usr/include/g++/map:35,
                 from twincpp.cc:4:
/usr/include/g++/stl_map.h:200: warning: friend declaration `bool operator ==(const class map<Key,T,Compare,Alloc> &, const class map<Key,T,Compare,Alloc> &)'
/usr/include/g++/stl_map.h:200: warning:   will not be treated as a template instantiation
/usr/include/g++/stl_map.h:201: warning: friend declaration `bool operator <(const class map<Key,T,Compare,Alloc> &, const class map<Key,T,Compare,Alloc> &)'
/usr/include/g++/stl_map.h:201: warning:   will not be treated as a template instantiation
In file included from /usr/include/g++/map:36,
                 from twincpp.cc:4:
/usr/include/g++/stl_multimap.h:194: warning: friend declaration `bool operator ==(const class multimap<Key,T,Compare,Alloc> &, const class multimap<Key,T,Compare,Alloc> &)'
/usr/include/g++/stl_multimap.h:194: warning:   will not be treated as a template instantiation
/usr/include/g++/stl_multimap.h:195: warning: friend declaration `bool operator <(const class multimap<Key,T,Compare,Alloc> &, const class multimap<Key,T,Compare,Alloc> &)'
/usr/include/g++/stl_multimap.h:195: warning:   will not be treated as a template instantiation
twincpp.cc: In function `void twin(InputIterator, InputIterator, OutputIterator)':
twincpp.cc:38: Internal compiler error.
twincpp.cc:38: Please submit a full bug report to `egcs-bugs@cygnus.com'.

// Twins

#include <algorithm>
#include <map>

template <class InputIterator,
  class OutputIterator,
  class Predicate,
  class UnaryOperation>
void
transform_if(InputIterator first,
             InputIterator last,
             OutputIterator result,
             Predicate pred,
             UnaryOperation op)
{
  while (first != last) {
    if (pred(*first)) {
      *result++ = op(*first);
    }
    ++first;
  }
  return result;
}


template <class InputIterator,
          class OutputIterator>
void
twin(InputIterator first,
     InputIterator last,
     OutputIterator result)
{
  // Could lift out.
  typedef map<typename InputIterator::value_type,
             int,
             less<int> > Map;
  struct {
    Map count;
    void operator()(typename InputIterator::value_type x) {
      ++count[x];
    }
  } insert;

  for_each(first,
           last,
           insert);

  struct {
    bool operator()(typename Map::value_type p) {
      return p.second == 2;
    }
  } equal2;

  struct {
    typename Map::key_type operator()(typename Map::value_type p) {
      return p.first;
    }
  } value;

  transform_if(insert.count.begin(),
               insert.count.end(),
               equal2,
               value);
}


// Example.

#include <iostream.h>

int
main()
{
  int foo[] = { 1, 2, 4, 666, 7, 2, 5, 5, 4, 5, 6, 7 };
  twin(foo,
       &foo[sizeof foo / sizeof foo[0]],
       ostream_iterator(cout));
}

-- 
Franklin Chen                     mailto:chen+@cs.cmu.edu
Graduate Student                  http://www.cs.cmu.edu/~chen/
Computer Science Department       Wean Hall 8218
Carnegie Mellon University


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