C++ error when using std::vector on mingw and powershell

Viewed 82

I have come across some strage behaviour when executing a simple program that uses std::vector with powershell

#include <vector>
#include <iostream>

int main() {
  auto v = std::vector<int>{};
  v.push_back(0);  

  std::cout << "Hello, World!\n";

  return 0;
}

g++ -v returns gcc version 11.2.0 (Rev10, Built by MSYS2 project)

I then compile the program with g++ main.cpp -o main.exe and i get an output executable.

When I run .\main.exe with powershell I get no console output but when i run the same executable with git bash I get Hello, World! printed to the console.

Ive tested both Powershell 7 and Windows PowerShell.

When I remove the both lines that have to do wiht std::vector it works in both shells.

When I run the executbale from 'cmd' I get the following error message enter image description here

0 Answers
Related