std::ofstream doesn’t work with short enums in C++Builder 10.3

  access-violation, c++, c++builder, ofstream, short

If I set "Short enums" to true (Project -> Options -> C++ Compiler), I receive an Access Violation in return from a function where std::ofstream is used.

Example code:

#include <iostream>
#include <fstream>

void __fastcall TForm1::FormCreate(TObject *Sender)
    AnsiString textFile = "err.txt";
    std::ofstream out;;
    out << textFile.c_str();

Does anyone know how to use short enums and still work with std::ofstream?

PS it’s legacy code and I can’t change the size of every enum in the project like
enum MyEnum : byte.

Source: Windows Questions C++