C++ runtime problem in windows

Revision en6, by notwatermango, 2022-02-20 17:21:40

Hello CF

I write this blog because I encountered a rather weird issue, maybe anyone here has the same issue or even has solved this? I was participating in a contest earlier when I tried to compile & run for problem B and my code doesn't run.

Here's the thing:

This compiles and run, I can see Hello printed in my terminal

#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> v;
  cout << "Hello";
  // v.push_back(2);
  return 0;
}

However when I uncomment v.push_back(2) my code compiles but doesn't run! (I don't see Hello in terminal)

Commands I used: g++ main.cpp -Wall -o main .\main.exe

There's no warning or error message.

I have tried compiling with MSYS64 (my main) and MSVC x64, same results.

Yesterday it was working fine, so maybe something broke my c++ runtime today.

Here's a list of what I did today before running to this problem (while in a contest ╯︿╰ ):

  • installed Anaconda,
  • installed git,
  • installed Visual Studio and C/C++ build toolchain (for rust),
  • installed rust

Similar problem: https://stackoverflow.com/questions/70809283/c-program-does-not-run-if-a-vector-has-any-contents https://stackoverflow.com/questions/70994977/c-code-wont-run-if-a-vector-contains-value

I'd love to participate in that post's comment section however I don't have enough karma.

Someone mentioned

Spoiler

Then I tried Visual Studio IDE and it works! Sadly VS complains when I do int arr[n]; saying array size should be static.

I'm considering IDEs since text editor has this issue (I implied IDE is OK because Visual Studio is OK), maybe I'll go with DevC++.

Tags compiler, c++, gcc, sad

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en10 English notwatermango 2022-02-20 17:35:11 0 (published)
en9 English notwatermango 2022-02-20 17:34:06 58
en8 English notwatermango 2022-02-20 17:30:45 128
en7 English notwatermango 2022-02-20 17:24:09 33
en6 English notwatermango 2022-02-20 17:21:40 380
en5 English notwatermango 2022-02-20 17:16:52 4
en4 English notwatermango 2022-02-20 17:16:10 2 Tiny change: 'Hello CF\nI write ' -> 'Hello CF\n\nI write '
en3 English notwatermango 2022-02-20 17:15:52 390
en2 English notwatermango 2022-02-20 17:07:59 509
en1 English notwatermango 2022-02-20 16:58:14 702 Initial revision (saved to drafts)