0

I had been running C++ programs with G++17 quite comfortably, when one day for no apparent reason, this error shows up:

internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:190: MapViewOfFileEx: Attempt to access invalid address.

Below is the complete error output:

[Finished in 4.5s with exit code 1]
[cmd: ['g++.exe', '-std=c++17', '-D DIV_DEBUG', 'D:\\Codes\\code.cpp', '-o', 'code.exe', '&&', 'code.exe<inputf.in>outputf.in']]
[dir: D:\Codes]
[path: C:\Python38\Scripts\;C:\Python38\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\MinGW\bin;C:\ProgramData\pbox;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\asus\AppData\Local\Microsoft\WindowsApps;C:\Users\asus\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\tools;C:\Users\asus\AppData\Roaming\npm;C:\Users\asus\AppData\Local\atom\bin]

I've been searching for a solution for three days now and haven't found it yet. It looks like a bug in MinGW but I do not know how to fix this. My last option is to delete everything related to MinGW and reinstall it. Any better ideas are appreciated.

The code which I'm trying to compile.

#include <bits/stdc++.h>

int main() {
    std::cout << "Hello, World!\n";
    return 0;
}

It appears that removing the "bits/stdc++.h" header file removes this error. I would still like to know how I can fix this as I use this library on a daily basis for all my programs.

Edit: I tried building on Windows Powershell but the same error comes up.

PS D:\Codes> g++.exe -std=c++17 -D DIV_DEBUG code.cpp -o code.exe
internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:190: MapViewOfFileEx: Attempt to access invalid address.

Update: Tried reinstalling MinGW. It didn't work.

  • What is the code being compiled? – IlCapitano Aug 21 '20 at 15:03
  • Updated question to include code. – Divyansh Hardia Aug 21 '20 at 15:24
  • You have your answer, it seems. Don't use that garbage include. – sweenish Aug 21 '20 at 15:41
  • @sweenish To some extent, I agree with your assessment of the include as garbage but I've found that this issue has been faced by many people in different programs whence this include was absent. I went through the code of the config file and it appears there's a failure in detection/allocation of some address. Even though the problem is fixed for me now, I'd still like to know what caused it in the first place. – Divyansh Hardia Aug 21 '20 at 15:47
  • To an extent? It is a garbage include. It's an everything and the kitchen sink include. That means it bloats your executable unnecessarily. It's an implementation detail, i.e., not part of the standard. Compilers may or may not support it. It makes it difficult to know what libraries you are using. It is a garbage include. https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h – sweenish Aug 21 '20 at 15:56
  • Duplicate of [this](https://stackoverflow.com/q/61916030/1983398)? – ssbssa Aug 24 '20 at 10:24
  • @ssbssa The question you linked has very little information but it looks like a similar issue. – Divyansh Hardia Aug 25 '20 at 18:32

1 Answers1

0

Okay, so the issue went as miraculously as it had appeared. I precompiled the header files after reinstalling MinGW and for some reason, it fixed the issue. I'm not sure if this action triggered the fix.

If someone can throw some light on this strange behaviour, I would mark that answer as accepted.

  • You were told that it's use of `bits/stdc++.h` does that. It's a header not meant to be used by user, hence it in folder `bits`. Sadly, a lot of outdated and sloppy tutorials refer to it. You had over-bloated memory of 32bit compiler by using that, precompiling it saved you some memory at cost of compile time. – Swift - Friday Pie Aug 29 '20 at 09:03