0

Calling std::ifstream destructor causes runtime error and crashes the program. The thing happens on Windows compiling with Borland Compiler 5.5. Unfortunately, I have to use this compiler, so switching to GCC or MSVC is not an option. Here's the sample code:

#include <iostream>
#include <fstream>

using namespace std;

void createDestroyStream()
{
    ifstream s1;
    cout << "Stream created!" << endl;
}

int main()
{
    char c;
    createDestroyStream();
    cout << "Done!" << endl;
    cin >> c;
    return 0;
}

The console output shows "Stream created!" and then the process is terminated with error code -1073741510. Can I do something with it?

Rames
  • 918
  • 11
  • 27
  • 1
    For years and years C++Builder had this problem with istream/ostream objects, it'd just crash on trying to destroy the object - sometimes. Try using the switch to do static link against RTL (don't recall what it is offhand) – M.M Sep 27 '15 at 12:33
  • If this is the real code, and it crashes when compiled with Builder, just ran from it fast as you can. This compiler is beyond salvation. Why are you even thinking of using it? – SergeyA Sep 27 '15 at 13:23
  • @SergeyA I have an library for specific device which works only with BCC. There's no version for GCC or MSVC and I don't have it's source code. – Rames Sep 27 '15 at 13:34
  • @Rames, in this case, I suggest you create a very thin wrapper library around, which will expose all it's interfaces in C style. Than you can work with the library through this interface. – SergeyA Sep 27 '15 at 22:48
  • @Rames it looks like issue with corrupted memory manager see [bds 2006 C hidden memory manager conflicts](http://stackoverflow.com/a/18016392/2521214) this is how I found out the problem [mmap](http://stackoverflow.com/a/20565511/2521214) inside huge project with 256K+ pointers Also a good idea is to use CodeGuard but for huge projects it is unusable (slow and runs out of memory fast) – Spektre Sep 28 '15 at 06:30

0 Answers0