3

I have a project which builds fine under gcc 4.8.4. I tried building using gcc 7, and noticed a lot of -Wimplicit-fallthrough= warnings. As far as I'm aware, this was indeed added in gcc version 7. I'm now using -Wno-implicit-fallthrough when building to suppress these warnings. Moving back to the older version of gcc, keeping the -Wno-implicit-fallthrough compiler flag does not lead to any error, even though I do not believe that gcc 4 recognizes this option. How come? Are specifically the -Wno- options allowed to not be recognized?

jmd_dk
  • 12,125
  • 9
  • 63
  • 94

1 Answers1

5

From man gcc:

When an unrecognized warning option is requested (e.g., -Wunknown-warning), GCC emits a diagnostic stating that the option is not recognized. However, if the -Wno- form is used, the behavior is slightly different: no diagnostic is produced for -Wno-unknown-warning unless other diagnostics are being produced. This allows the use of new -Wno- options with old compilers, but if something goes wrong, the compiler warns that an unrecognized option is present.

To sum it up: if all goes well, unknown -Wno-* switches are ignored to preserve compatibility.

cadaniluk
  • 15,027
  • 2
  • 39
  • 67