codeql-coding-standards icon indicating copy to clipboard operation
codeql-coding-standards copied to clipboard

`A1-1-2`: does not understand -Wno-* flags

Open MichaelRFairhurst opened this issue 1 year ago • 1 comments

Affected rules

  • A1-1-2

Description

This rule looks for compilations with no warning flags. However, it will falsely detect -Wno-* flags as if they are warning flags.

Notably, gcc is often built with -Wformat enabled by default. This can be suppressed with -Wno-format, which would cause the false negative.

Note the same issue exists with -w which suppresses all -W* flags, which is failing linux/gcc tests, and I created https://github.com/github/codeql-coding-standards/pull/688 to fix. However, this issue is, philosophically, one step further yet than that PR in terms of altering current behavior.

Example

g++ -Wno-format test.cpp

MichaelRFairhurst avatar Sep 17 '24 00:09 MichaelRFairhurst

It looks like we'll have the same false negative in the case of -Wformat=0. This will have to be addressed at the same time in order to satisfy CI/CD tests, as it appears our extractor mimic functionality translates -Wno-format to -Wformat=0, which we have to use in order to suppress the gcc default flag of -Wformat. Easy to fix both at the same time, however.

MichaelRFairhurst avatar Sep 18 '24 20:09 MichaelRFairhurst