name-mangling bug

Stephen Vavasis vavasis@CS.Cornell.EDU
Thu Sep 24 18:22:00 GMT 1998


When I tried to link my application, the linker complained of one
undefined function.  Further investigation showed that the name-mangler
added an extra underscore to the name of one of my functions, i.e., it
named the function "eatwhite_" instead of "eatwhite" leading to the
linker error.  An example of this behavior is attached.

-- Steve Vavasis

--------------------------- commands demonstrating the bug

syn.cs.cornell.edu> g++ -c -v testmang.cpp
g++ -c -v testmang.cpp
Reading specs from
/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)

/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__
-D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) testmang.cpp /var/tmp/ccb0TsRi.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gnu/egcs-1.1b/include/g++
 /usr/local/include
 /usr/local/gnu/egcs-1.1b/sparc-sun-solaris2.5/include

/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/include
 /usr/include
End of search list.

/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/cc1plus
/var/tmp/ccb0TsRi.ii -quiet -dumpbase testmang.cc -version -o
/var/tmp/ccVuFnUP.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release)
(sparc-sun-solaris2.5) compiled by GNU C version egcs-2.91.57 19980901
(egcs-1.1 release).
 /usr/ccs/bin/as -V -Qy -s -o testmang.o /var/tmp/ccVuFnUP.s
/usr/ccs/bin/as: SC4.2 dev 30 Nov 1995
syn.cs.cornell.edu> nm testmang.o | grep eatwhite |
/usr/local/gnu/egcs-1.1b/bin/c++filt
nm testmang.o | grep eatwhite | /usr/local/gnu/egcs-1.1b/bin/c++filt

[8]     |         0|     192|FUNC |GLOB |0    |2     
|QMG::eatwhite_(istream &)
syn.cs.cornell.edu>


------------------ source file


#include <cctype>
#include <iostream>
#include <string>


using std::istream;
using std::isspace;
using std::toupper;

namespace QMG {

  
  // Eat the white characters in an istream

  istream& eatwhite(istream& is) {
    char c;
    for (;;) {
      if (!is.get(c))
        break;
      if (!isspace(c)) {
        is.putback(c);
        break;
      }
    }
    return is;
  }
  
}



More information about the Gcc-bugs mailing list