Why does -Wfatal-errors turn off notes about the error, and how do I turn notes back on?

Viewed 53

I often build with -Wfatal-errors because I don't need an extra 100 meaningless errors while the compiler heroically tries to parse the rest of a source file after a typo that renders it meaningless.

However, I've noticed that this also turns off diagnostic notes about the fatal error itself. For instance, with -Wfatal-errors I will get, say,

main.cpp:10:2: error: invalid new-expression of abstract class type 'C'
  new C();

whereas if I don't have -Wfatal-errors on, I will get a note telling me which virtual method I forgot to implement:

class.hpp:15:2 note: because the following virtual functions are pure within 'C':
class.hpp:28:6   void C::f()

Can I get these notes back while still keeping the behavior where I terminate after a single error?

1 Answers

You're looking for -fmax-errors=1. This will terminate compilation after the first error, but still show the notes for that error.

Here's a demo to compare the effects of these flags.

Related