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]

Repository fails on i586-linux (2.2.13)


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;
}

#include "x.h"

bool XCompare::operator()(const X* l, const X* r) const
{
  bool value;

  switch(x)
  {
  case A:
    {
      value = (l->a < r->a);
      break;
    }
  case B:
    {
      value = (l->b < r->b);
      break;
    }
  case C:
    {
      value = (l->c < r->c);
      break;
    }
  default:
    cout << "HIDEOUS ERROR!!!!!" << endl;
    throw 0;
  }

  return value;
}

// X.h
#ifndef X_h
#define X_h

#include <iostream>
#include <functional>  // declares binary_function and not2

using namespace std;

class XCompare;

class X{
public:
  X(int ia = 0, int ib = 0, int ic = 0):
      a(ia),
      b(ib),
      c(ic)
  {
  }

  void print() const
  {
    cout << a << "," << b << "," << c << " ";
  }

  bool operator<(const X& rhs) const
  {
    return a < rhs.a;
  }

  bool operator==(const X& rhs) const
  {
    return (a == rhs.a) && (b == rhs.b) && (a == rhs.b);
  }

private:
  int a;
  int b;
  int c;
  friend class XCompare;
};

class XCompare : public binary_function<X*, X*, bool>
{
public:
  enum Xsort { A, B, C };
  XCompare(Xsort by=A) : x(by) {};
  bool operator()(const X* l, const X* r) const;
  void setx(Xsort new_x) { x = new_x; }
private:
  Xsort x;
};

#endif

CXX=g++
CXXFLAGS=-Wall -Wwrite-strings -Wshadow -Wmissing-declarations \
         -Wmissing-prototypes -Wstrict-prototypes -Wsign-compare \
         -O2 -felide-constructors \
         -fstrict-prototypes -fomit-frame-pointer

ifndef HACK
REPO=-frepo
endif
LDFLAGS=-Wall -Wl,-s

BINARIES=ex31
EX31SRC=main.cpp x.cpp
EX31OBJ=${EX31SRC:.cpp=.o}

STRIP=strip -p -R .note -R .comment
RM=rm -f

#####################################################################
# Rules
.PHONY: all tidy clean depend
all: ${BINARIES}

tidy:
	$(RM) core *.o *.bak *~

clean: tidy
	$(RM) ${BINARIES} *.rpo

depend: ${EX31SRC}
	@$(CXX) ${CXXDEFINE} -MM $^ > depend.mak 

#####################################################################
# Binary dependencies
ex31: ${EX31OBJ}
	$(CXX) ${LDFLAGS} -o $@ $^
	$(STRIP) $@

#####################################################################
# Object dependencies
%.o: %.cpp Makefile
	$(CXX) ${CXXFLAGS} -c ${REPO} $<

#####################################################################
# Dependencies
-include depend.mak

g++ -Wall -Wwrite-strings -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wsign-compare -O2 -felide-constructors -fstrict-prototypes -fomit-frame-pointer -c -frepo main.cpp
g++ -Wall -Wwrite-strings -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wsign-compare -O2 -felide-constructors -fstrict-prototypes -fomit-frame-pointer -c -frepo x.cpp
g++ -Wall -Wl,-s -o ex31 main.o x.o
collect: recompiling main.cpp
collect: relinking
main.o: In function `vector<X, allocator<X> >::_M_insert_aux(X *, X const &)':
main.o(.text+0x10f6): undefined reference to `__uninitialized_copy_aux__H2ZP1XZP1X_X01X01X11G12__false_type_X11'
main.o(.text+0x112b): undefined reference to `__uninitialized_copy_aux__H2ZP1XZP1X_X01X01X11G12__false_type_X11'
main.o: In function `void __introsort_loop<X *, X, int>(X *, X *, X *, int)':
main.o(.text+0x12ed): undefined reference to `void __partial_sort<X *, X>(X *, X *, X *, X *)'
main.o(.text+0x1380): undefined reference to `X * __unguarded_partition<X *, X>(X *, X *, X)'
main.o: In function `void __final_insertion_sort<X *>(X *, X *)':
main.o(.text+0x140f): undefined reference to `void __insertion_sort<X *>(X *, X *)'
main.o(.text+0x141e): undefined reference to `void __unguarded_insertion_sort_aux<X *, X>(X *, X *, X *)'
main.o(.text+0x142a): undefined reference to `void __insertion_sort<X *>(X *, X *)'
main.o: In function `void __introsort_loop<X **, X *, int>(X **, X **, X * *, int)':
main.o(.text+0x171d): undefined reference to `void __partial_sort<X **, X *>(X **, X **, X **, X * *)'
main.o(.text+0x177c): undefined reference to `X ** __unguarded_partition<X **, X *>(X **, X **, X *)'
main.o: In function `void __final_insertion_sort<X **>(X **, X **)':
main.o(.text+0x17d2): undefined reference to `void __insertion_sort<X **>(X **, X **)'
main.o(.text+0x17e1): undefined reference to `void __unguarded_insertion_sort_aux<X **, X *>(X **, X **, X * *)'
main.o(.text+0x17ed): undefined reference to `void __insertion_sort<X **>(X **, X **)'
main.o: In function `void __introsort_loop<X **, X *, int, XCompare>(X **, X **, X * *, int, XCompare)':
main.o(.text+0x185e): undefined reference to `void __partial_sort<X **, X *, XCompare>(X **, X **, X **, X * *, XCompare)'
main.o(.text+0x1945): undefined reference to `X ** __unguarded_partition<X **, X *, XCompare>(X **, X **, X *, XCompare)'
main.o: In function `void __final_insertion_sort<X **, XCompare>(X **, X **, XCompare)':
main.o(.text+0x19b3): undefined reference to `void __insertion_sort<X **, XCompare>(X **, X **, XCompare)'
main.o(.text+0x19c4): undefined reference to `void __unguarded_insertion_sort_aux<X **, X *, XCompare>(X **, X **, X * *, XCompare)'
main.o(.text+0x19d5): undefined reference to `void __insertion_sort<X **, XCompare>(X **, X **, XCompare)'
main.o: In function `void __introsort_loop<X **, X *, int, binary_negate<XCompare> >(X **, X **, X * *, int, binary_negate<XCompare>)':
main.o(.text+0x1a2f): undefined reference to `void __partial_sort<X **, X *, binary_negate<XCompare> >(X **, X **, X **, X * *, binary_negate<XCompare>)'
main.o(.text+0x1b31): undefined reference to `X ** __unguarded_partition<X **, X *, binary_negate<XCompare> >(X **, X **, X *, binary_negate<XCompare>)'
main.o: In function `void __final_insertion_sort<X **, binary_negate<XCompare> >(X **, X **, binary_negate<XCompare>)':
main.o(.text+0x1bc6): undefined reference to `void __insertion_sort<X **, binary_negate<XCompare> >(X **, X **, binary_negate<XCompare>)'
main.o(.text+0x1bfc): undefined reference to `void __unguarded_insertion_sort_aux<X **, X *, binary_negate<XCompare> >(X **, X **, X * *, binary_negate<XCompare>)'
main.o(.text+0x1c23): undefined reference to `void __insertion_sort<X **, binary_negate<XCompare> >(X **, X **, binary_negate<XCompare>)'
collect2: ld returned 1 exit status
make: *** [ex31] Error 1
M main.cpp
D /home/Chris/Programs/test/BUGS/repo
A '-Wall' '-Wwrite-strings' '-Wshadow' '-Wmissing-declarations' '-Wmissing-prototypes' '-Wstrict-prototypes' '-Wsign-compare' '-O2' '-felide-constructors' '-fstrict-prototypes' '-fomit-frame-pointer' '-c' '-frepo'
O __unguarded_insertion_sort_aux__H3ZPP1XZP1XZt13binary_negate1Z8XCompare_X01X01PX11X21_v
O __unguarded_insertion_sort__H2ZPP1XZt13binary_negate1Z8XCompare_X01X01X11_v
O __insertion_sort__H2ZPP1XZt13binary_negate1Z8XCompare_X01X01X11_v
O __unguarded_partition__H3ZPP1XZP1XZt13binary_negate1Z8XCompare_X01X01X11X21_X01
O __cl__Ct13binary_negate1Z8XCompareRCP1XT1
O __median__H2ZP1XZt13binary_negate1Z8XCompare_RCX01N20X11_RCX01
O __partial_sort__H3ZPP1XZP1XZt13binary_negate1Z8XCompare_X01X01X01PX11X21_v
O partial_sort__H2ZPP1XZt13binary_negate1Z8XCompare_X01X01X01X11_v
O __unguarded_insertion_sort_aux__H3ZPP1XZP1XZ8XCompare_X01X01PX11X21_v
O __unguarded_insertion_sort__H2ZPP1XZ8XCompare_X01X01X11_v
O __insertion_sort__H2ZPP1XZ8XCompare_X01X01X11_v
O __unguarded_partition__H3ZPP1XZP1XZ8XCompare_X01X01X11X21_X01
O __median__H2ZP1XZ8XCompare_RCX01N20X11_RCX01
O __partial_sort__H3ZPP1XZP1XZ8XCompare_X01X01X01PX11X21_v
O partial_sort__H2ZPP1XZ8XCompare_X01X01X01X11_v
O __unguarded_insertion_sort_aux__H2ZPP1XZP1X_X01X01PX11_v
O __unguarded_insertion_sort__H1ZPP1X_X01X01_v
O __insertion_sort__H1ZPP1X_X01X01_v
O __unguarded_partition__H2ZPP1XZP1X_X01X01X11_X01
O __median__H1ZP1X_RCX01N20_RCX01
O __partial_sort__H2ZPP1XZP1X_X01X01X01PX11_v
O partial_sort__H1ZPP1X_X01X01X01_v
O __copy_trivial__H1ZP1X_PCX01T0PX01_PX01
O copy__t15__copy_dispatch3ZPP1XZPP1XZ11__true_typePCP1XT1PP1X
O copy__H2ZPP1XZPP1X_X01X01X11_X11
O __uninitialized_copy_aux__H2ZPP1XZPP1X_X01X01X11G11__true_type_X11
O __uninitialized_copy__H3ZPP1XZPP1XZP1X_X01X01X11PX21_X11
O uninitialized_copy__H2ZPP1XZPP1X_X01X01X11_X11
O allocate__t12simple_alloc2ZP1XZt24__default_alloc_template2b1i0Ui
O _M_allocate__t18_Vector_alloc_base3ZP1XZt9allocator1ZP1Xb1Ui
O end__Ct6vector2ZP1XZt9allocator1ZP1X
O begin__Ct6vector2ZP1XZt9allocator1ZP1X
O size__Ct6vector2ZP1XZt9allocator1ZP1X
O copy__t24__copy_backward_dispatch3ZPP1XZPP1XZ11__true_typePCP1XT1PP1X
O copy_backward__H2ZPP1XZPP1X_X01X01X11_X11
O __unguarded_insertion_sort_aux__H2ZP1XZ1X_X01X01PX11_v
O __unguarded_insertion_sort__H1ZP1X_X01X01_v
O __insertion_sort__H1ZP1X_X01X01_v
O __unguarded_partition__H2ZP1XZ1X_X01X01X11_X01
O __median__H1Z1X_RCX01N20_RCX01
O __partial_sort__H2ZP1XZ1X_X01X01X01PX11_v
O partial_sort__H1ZP1X_X01X01X01_v
O __uninitialized_copy_aux__H2ZP1XZP1X_X01X01X11G12__false_type_X11
O __uninitialized_copy__H3ZP1XZP1XZ1X_X01X01X11PX21_X11
O uninitialized_copy__H2ZP1XZP1X_X01X01X11_X11
O _S_refill__t24__default_alloc_template2b1i0Ui
O _S_round_up__t24__default_alloc_template2b1i0Ui
O _S_oom_malloc__t23__malloc_alloc_template1i0Ui
O allocate__t23__malloc_alloc_template1i0Ui
O allocate__t24__default_alloc_template2b1i0Ui
O allocate__t12simple_alloc2Z1XZt24__default_alloc_template2b1i0Ui
O _M_allocate__t18_Vector_alloc_base3Z1XZt9allocator1Z1Xb1Ui
O __copy_backward__H3ZP1XZP1XZi_X01X01X11G26random_access_iterator_tagPX21_X11
O copy__t24__copy_backward_dispatch3ZP1XZP1XZ12__false_typeP1XN21
O copy_backward__H2ZP1XZP1X_X01X01X11_X11
C __final_insertion_sort__H2ZPP1XZt13binary_negate1Z8XCompare_X01X01X11_v
C __introsort_loop__H4ZPP1XZP1XZiZt13binary_negate1Z8XCompare_X01X01PX11X21X31_v
O sort__H2ZPP1XZt13binary_negate1Z8XCompare_X01X01X11_v
O __t13binary_negate1Z8XCompareRC8XCompare
O not2__H1Z8XCompare_RCX01_t13binary_negate1ZX01
C __final_insertion_sort__H2ZPP1XZ8XCompare_X01X01X11_v
C __introsort_loop__H4ZPP1XZP1XZiZ8XCompare_X01X01PX11X21X31_v
O sort__H2ZPP1XZ8XCompare_X01X01X11_v
C for_each__H2ZPP1XZPFPC1X_v_X01X01X11_X11
C __final_insertion_sort__H1ZPP1X_X01X01_v
C __introsort_loop__H3ZPP1XZP1XZi_X01X01PX11X21_v
O sort__H1ZPP1X_X01X01_v
O begin__t6vector2ZP1XZt9allocator1ZP1X
C _M_insert_aux__t6vector2ZP1XZt9allocator1ZP1XPP1XRCP1X
O end__t6vector2ZP1XZt9allocator1ZP1X
O construct__H2ZP1XZP1X_PX01RCX11_v
O push_back__t6vector2ZP1XZt9allocator1ZP1XRCP1X
O _._t9allocator1ZP1X
O __t18_Vector_alloc_base3ZP1XZt9allocator1ZP1Xb1RCt9allocator1ZP1X
O __t12_Vector_base2ZP1XZt9allocator1ZP1XRCt9allocator1ZP1X
O __t6vector2ZP1XZt9allocator1ZP1XRCt9allocator1ZP1X
O __t9allocator1ZP1X
O deallocate__t12simple_alloc2ZP1XZt24__default_alloc_template2b1i0PP1XUi
O _M_deallocate__t18_Vector_alloc_base3ZP1XZt9allocator1ZP1Xb1PP1XUi
O _._t12_Vector_base2ZP1XZt9allocator1ZP1X
O __destroy_aux__H1ZPP1X_X01X01G11__true_type_v
O __destroy__H2ZPP1XZP1X_X01X01PX11_v
O __value_type__H1ZPP1X_RCX01_PQ2t15iterator_traits1ZX0110value_type
O destroy__H1ZPP1X_X01X01_v
O _._t6vector2ZP1XZt9allocator1ZP1X
C __final_insertion_sort__H1ZP1X_X01X01_v
C __introsort_loop__H3ZP1XZ1XZi_X01X01PX11X21_v
O __lg__H1Zi_X01_X01
O sort__H1ZP1X_X01X01_v
C for_each__H2ZP1XZPFRC1X_v_X01X01X11_X11
O __ml__Ct16reverse_iterator1ZP1X
O __rf__Ct16reverse_iterator1ZP1X
O __pp__t16reverse_iterator1ZP1X
O base__Ct16reverse_iterator1ZP1X
O __eq__H1ZP1X_RCt16reverse_iterator1ZX01T0_b
O __ne__H1Zt16reverse_iterator1ZP1X_RCX01T0_b
O rend__t6vector2Z1XZt9allocator1Z1X
O __t16reverse_iterator1ZP1XRCt16reverse_iterator1ZP1X
O __t16reverse_iterator1ZP1XP1X
O rbegin__t6vector2Z1XZt9allocator1Z1X
O begin__t6vector2Z1XZt9allocator1Z1X
O __vc__t6vector2Z1XZt9allocator1Z1XUi
O end__Ct6vector2Z1XZt9allocator1Z1X
O begin__Ct6vector2Z1XZt9allocator1Z1X
O size__Ct6vector2Z1XZt9allocator1Z1X
C _M_insert_aux__t6vector2Z1XZt9allocator1Z1XP1XRC1X
O end__t6vector2Z1XZt9allocator1Z1X
O construct__H2Z1XZ1X_PX01RCX11_v
O push_back__t6vector2Z1XZt9allocator1Z1XRC1X
O _._t9allocator1Z1X
O __t18_Vector_alloc_base3Z1XZt9allocator1Z1Xb1RCt9allocator1Z1X
O __t12_Vector_base2Z1XZt9allocator1Z1XRCt9allocator1Z1X
O __t6vector2Z1XZt9allocator1Z1XRCt9allocator1Z1X
O __t9allocator1Z1X
O __Q2t24__default_alloc_template2b1i0_5_Lock
O _t24__default_alloc_template2b1i0._S_node_allocator_lock
O _._Q2t24__default_alloc_template2b1i0_5_Lock
O _S_freelist_index__t24__default_alloc_template2b1i0Ui
O _t24__default_alloc_template2b1i0._S_free_list
O deallocate__t23__malloc_alloc_template1i0PvUi
O deallocate__t24__default_alloc_template2b1i0PvUi
O deallocate__t12simple_alloc2Z1XZt24__default_alloc_template2b1i0P1XUi
O _M_deallocate__t18_Vector_alloc_base3Z1XZt9allocator1Z1Xb1P1XUi
O _._t12_Vector_base2Z1XZt9allocator1Z1X
O destroy__H1Z1X_PX01_v
O __destroy_aux__H1ZP1X_X01X01G12__false_type_v
O __destroy__H2ZP1XZ1X_X01X01PX11_v
O __value_type__H1ZP1X_RCX01_PQ2t15iterator_traits1ZX0110value_type
O destroy__H1ZP1X_X01X01_v
O _._t6vector2Z1XZt9allocator1Z1X
O __lexicographical_compare_3way__H2ZPCScZPCSc_X01X01X11X11_i
O min__H1Zi_RCX01T0_RCX01
O lexicographical_compare__H2ZPCScZPCSc_X01X01X11X11_b
O min__H1ZUi_RCX01T0_RCX01

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