[Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
gregoryk at edifecs dot com
gcc-bugzilla@gcc.gnu.org
Tue Mar 27 17:39:00 GMT 2007
------- Comment #10 from gregoryk at edifecs dot com 2007-03-27 18:39 -------
Got it, thanks. In may original test I was relaying on LD_LIBRARY_PATH to have
current folder in the values. And there was no checking of dlopen result for
simplicity. Here is updated code. It will search for libloader.so in current
folder.
#include <dlfcn.h>
#include <string>
#include "loader.h"
typedef void *pfLoader(std::ustring&);
int main(int argc, char* argv[])
{
void * libHandle = dlopen("./libloader.so", RTLD_NOW|RTLD_GLOBAL);
if (0 == libHandle)
{
printf("Can not load \"./libloader.so\".\n");
return 1;
}
pfLoader* pF = (pfLoader*)dlsym(libHandle, "read_string");
if (0 == pF)
{
printf("Can not find function \"read_string\" in
libloader.so\n");
return 2;
}
std::ustring s;
// s.reserve(1); // uncomment this line to prevent abort
pF(s);
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31368
More information about the Gcc-bugs
mailing list