Repository fails on i586-linux (2.2.13)
Chris Rankin
rankinc@zip.com.au
Wed Oct 27 03:28:00 GMT 1999
Hi,
I saw that a repository bug had been fixed in gcc-2.95.2 (to do with
leading underscores in mangled names). Therefore I was rather hoping
that the following "unit test" program would succeed this time round. No
such luck. As you can see, the failure is rather spectacular...
I am using i586-pc-linux-gnu with binutils 2.9.5 (Linux 2.2.13,
glibc-2.1.2 if that makes any difference).
Cheers,
Chris.
// main.cpp
#include "x.h"
#include <vector>
#include <algorithm> // declares "for_each"
#include <functional> // declares "not2"
using namespace std;
void xPrint(const X &x)
{
x.print();
}
void xPtrPrint(const X *px)
{
px->print();
}
int main()
{
// insert code here
vector<X> xVec;
// Define our objects to be sorted
X x1(7,4,2);
X x2(3,1,5);
X x3(4,6,3);
X x4(2,10,8);
X x5(11,9,4);
// Put our objects into a vector (in any order)
xVec.push_back( x1 );
xVec.push_back( x2 );
xVec.push_back( x3 );
xVec.push_back( x4 );
xVec.push_back( x5 );
// Basic method: show vector's contents
cout << "Part 1" << endl;
for (size_t i=0; i < xVec.size(); ++i)
{
xVec[i].print();
}
// Print using an iterator
cout << endl << "Part 2" << endl;
for (vector<X>::iterator iter = xVec.begin();
iter != xVec.end();
++iter)
{
iter->print();
}
cout << endl;
// Print backwards, using an iterator
cout << endl << "Part 3" << endl;
for (vector<X>::reverse_iterator r_iter = xVec.rbegin();
r_iter != xVec.rend();
++r_iter)
{
r_iter->print();
}
cout << endl;
// Loop through vector without using a for loop
cout << "Part 4" << endl;
for_each(xVec.begin(), xVec.end(), &xPrint);
cout << endl;
// Sort the vector
cout << "Part 5" << endl;
sort(xVec.begin(), xVec.end());
for_each(xVec.begin(), xVec.end(), &xPrint);
cout << endl;
// Exercise 3.2
cout << endl;
// Create a reference container of our objects (a vector)
vector<X*> xPtrVec;
xPtrVec.push_back( &x1 );
xPtrVec.push_back( &x2 );
xPtrVec.push_back( &x3 );
xPtrVec.push_back( &x4 );
xPtrVec.push_back( &x5 );
// Show that reference containers can't be sorted
// like value containers
cout << "Fail-sort" << endl;
sort(xPtrVec.begin(), xPtrVec.end());
for_each(xPtrVec.begin(), xPtrVec.end(), &xPtrPrint);
cout << endl;
// Create a comparison functor
XCompare xcomp;
// Show that the functor sorts the reference container
cout << "Good-sort" << endl;
sort(xPtrVec.begin(), xPtrVec.end(), xcomp);
for_each(xPtrVec.begin(), xPtrVec.end(), &xPtrPrint);
cout << endl;
// Explicitly sort by "A"
cout << "Sort By A" << endl;
xcomp.setx(XCompare::A);
sort(xPtrVec.begin(), xPtrVec.end(), xcomp);
for_each(xPtrVec.begin(), xPtrVec.end(), &xPtrPrint);
cout << endl;
// Explicitly sort by "B"
cout << "Sort by B" << endl;
xcomp.setx(XCompare::B);
sort(xPtrVec.begin(), xPtrVec.end(), xcomp);
for_each(xPtrVec.begin(), xPtrVec.end(), &xPtrPrint);
cout << endl;
// Explicitly sort by "C"
cout << "Sort by C" << endl;
xcomp.setx(XCompare::C);
sort(xPtrVec.begin(), xPtrVec.end(), xcomp);
for_each(xPtrVec.begin(), xPtrVec.end(), &xPtrPrint);
cout << endl;
// Use the not2 function adaptor to reverse the sort
cout << "Reverse sort by C" << endl;
sort(xPtrVec.begin(), xPtrVec.end(), not2(xcomp));
for_each(xPtrVec.begin(), xPtrVec.end(), &xPtrPrint);
cout << endl;
return 0;
}
More information about the Gcc-bugs
mailing list