This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
- From: "gregoryk at edifecs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Mar 2007 17:39:41 -0000
- Subject: [Bug libstdc++/31368] basic_string and unsigned short leads to memory fault
- References: <bug-31368-14317@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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