internal compiler error using -Wall
gustavo
gustavo@geneura.ugr.es
Thu Apr 27 08:54:00 GMT 2000
Hi,
This is a little program that makes g++ crash when option "-Wall"÷ is
used. Without "-Wall" everything goes all right :(
Cheers
Gustavo
//-----------------------------------------------------------------------------
// bug2.cc
//-----------------------------------------------------------------------------
#include <functional> // less
#include <iostream> // ostream
#include <vector> // vector
#include <algorithm> // count swap
//---------------------------------------------------------------------------
template <class Genotype, class Phenotype, class Translator, class Compare = less<Phenotype> > class eo: public Genotype
{
public:
typedef Genotype genotype;
typedef Phenotype phenotype;
typedef Translator translator;
typedef Compare compare;
eo(): valid(false) {}
const phenotype& fitness() const
{
if (!valid)
{
phenotype_ = translator_(*this);
valid = true;
}
return phenotype_;
}
bool operator<(const eo& other) const
{
return compare_(fitness(), other.fitness());
}
friend ostream& operator<<(ostream& os, const eo& e)
{
return os << static_cast<genotype>(e) << " " << e.fitness();
}
private:
mutable bool valid;
mutable phenotype phenotype_;
mutable translator translator_;
compare compare_;
};
//-----------------------------------------------------------------------------
class bit: public vector<bool>
{
public:
bit(): vector<bool>(8) {}
friend ostream& operator<<(ostream& os, const bit& b)
{
copy(b.begin(), b.end(), ostream_iterator<bool>(os));
return os;
}
};
struct max_ones
{
unsigned operator()(const vector<bool>& v) const
{
return count(v.begin(), v.end(), true);
}
};
typedef eo<bit, unsigned, max_ones > leo;
typedef eo<bit, unsigned, max_ones, greater<float> > geo;
//-----------------------------------------------------------------------------
main()
{
srand(time(0));
leo l1, l2;
geo g1, g2;
cout << l1 << endl << l2 << endl << g1 << endl << g2 << endl;
swap(l1, l2); swap(g1, g2);
cout << l1 << endl << l2 << endl << g1 << endl << g2 << endl;
}
//-----------------------------------------------------------------------------
More information about the Gcc-bugs
mailing list