ROOT crashes when I try to print integers, doubles or floats with cout or printing a new line with endl. However, printing strings with coutworks fine, printing new lines with \n works too and for example drawing histograms in TCanvas works well too.
I have no idea how to fix this, does anyone know where the problem comes from? Everything worked fine until yesterday evening while I changed nothng. See below for an example of what kind of code works and what crashes ROOT.
using namespace std;
#include<iostream>
#include "vector"
#include <string>
void test() {
string str = "Hello world!";
cout << str; // Works
cout << str << "\n"; // Works
cout << str << endl; // Crashes
int i = 2;
int j = 3 + 2;
cout << Form("i = %d", i); // Works
cout << Form("j = %d", j); // Works
cout << i; // Crashes
}
You said that it is a known issue on Windows. The weird thing is that everything was working ok, and suddenly not anymore. When I’m using endl or try to print anything else than a string, ROOT crashes.
Is it possible that ROOT upgrades automatically to a newer version and in the newer version this issue arises again? Because I don’t understand how else this issue suddenly can appear. I’ve had this issue before, but then it was solved the next day.
I’m using VS Code and I haven’t updated it, but it could be that it has update automatically. I’m not using Windows 10 SDK.
But even if I’m writing my code in Windows Notepad and the macro only consists of one line std::cout << 2; or std::cout << std::endl; makes ROOT crashes, while std::cout << "2"; or std::cout << Form("%d", 2); works fine.