gcc acknowledging -Wfatal-errors parameter but not acting upon it

368 views Asked by At

Using the parameter, after every error gcc prints out "compilation terminated due to -Wfatal-errors."

But it keeps going. Does not actually stop.

I use:

g++ (x86_64-win32-seh-rev1, Built by MinGW-W64 project) 4.9.2

Calling the compiler:

@echo off
set LIBRARY_PATH=D:\Projekte\C++\Arsenal of Democracy\sdk\Lib;C:\Program Files (x86)\Microsoft DirectX SDK (August 2008)\Lib\x86
set CPLUS_INCLUDE_PATH=D:\Projekte\C++\Arsenal of Democracy\sdk\Include;C:\Program Files (x86)\Microsoft DirectX SDK (August 2008)\Include

cd src
g++ -m32 -mwindows -w -Wfatal-errors -std=c++14 -o ../AODGame.exe *.cpp
cd ..

Compilation time is about the same as without the parameter. Number of errors is also the same.

However, if I construct a minimal example:

int main()
{
  cout << "Bla." << endl; // 1st error - should abort here
  t - q = v;              // 2nd error - should not reach nor report
}

and compile that with

g++ -Wfatal-errors -o Test Test.cpp

Then it does work and the second error never shows up (and it does without the parameter).

What might be the cause of this irregularity? How can I circumvent it?

Obviously I do not care whether compilation of a tiny example is aborted or not, but with a real project the time saved is - or rather would be - actually valuable.

I have searched for this problem and only found ~two years old topics about different problems with the same parameter (not working on Clang, not included in gcc 3.x, etc.), none of which seems to be applicable here.

--

To follow @David Macek's comment, a minimal example with the same type of first error is

#include <vector>

using namespace std;

template<class X> void test(vector<X> & v)
{
  vector<X>::iterator i = v.begin();
}

int main()
{
  t - v = q;
}

It, too, correctly terminates after the very first error and never reaches the expression in main.

0

There are 0 answers