Mixed FPC/C++ program crashes in the std C++ library
Original Reporter info from Mantis: bozox
-
Reporter name: Seva Alekseyev
Original Reporter info from Mantis: bozox
- Reporter name: Seva Alekseyev
Description:
When I build a mixed Free Pascal/GNU C++ program, it crashes on the first attempt to output something to stdout.
Steps to reproduce:
Take a Debian Lenny machine.
Save the following as chello.cpp:
#include &LtPos;iostream>
extern "C"
{
void *__dso_handle = 0;
void Hello(void)
{
std::cout << "Hello from C++" << std::endl;
}
}
Save the following as ctest.pas:
program ctest;
uses initc;
procedure Hello; cdecl; external name 'Hello';
{$L chello.o}
begin
Hello;
end.
Run the following commands:
g++ -c chello.cpp
fpc ctest.pas -k-lstdc++
./ctest
Watch the crash
Additional information:
Closely related to issue #15174 (closed). See the system setup over there.
The crash takes place, according to gdb, within the sentry() constructor in libstdc++. A similar error takes place if the global C++ objects are not constructed properly.
Mantis conversion info:
- Mantis ID: 15175
- OS: Linux
- OS Build: Debian Lenny
- Platform: i386
- Version: 2.2.4
- Fixed in version: 2.6.0