Comment 1 for bug 1317305

Steve Beattie (sbeattie) wrote :

Here is an updated version of the gcc-default-format-security.diff patch that enables -Wformat=1 and -Wformat-security by default, but honors users' -Wformat arguments to override the default.

This fixes the following gcc testcase failures:

-FAIL: gcc.dg/format/nonlit-2.c -Wformat=0 non-literal (test for warnings, line 11)
-FAIL: gcc.dg/format/nonlit-2.c -Wformat=0 non-literal (test for warnings, line 12)
-FAIL: gcc.dg/format/nonlit-2.c -DWIDE -Wformat=0 non-literal (test for warnings, line 11)
-FAIL: gcc.dg/format/nonlit-2.c -DWIDE -Wformat=0 non-literal (test for warnings, line 12)
-FAIL: gcc.dg/format/opt-1.c -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-1.c -DWIDE -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-2.c -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-2.c -DWIDE -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-3.c -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-3.c -DWIDE -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-4.c -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-4.c -DWIDE -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-5.c -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-5.c -DWIDE -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-6.c -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/opt-6.c -DWIDE -Wformat=0 ignored (test for warnings, line )
-FAIL: gcc.dg/format/plus-1.c -Wformat=0 non-constant addend (test for warnings, line 16)
-FAIL: gcc.dg/format/plus-1.c -Wformat=0 minus constant (test for warnings, line 18)
-FAIL: gcc.dg/format/plus-1.c -Wformat=0 negative addend (test for warnings, line 19)
-FAIL: gcc.dg/format/plus-1.c -DWIDE -Wformat=0 non-constant addend (test for warnings, line 16)
-FAIL: gcc.dg/format/plus-1.c -DWIDE -Wformat=0 minus constant (test for warnings, line 18)
-FAIL: gcc.dg/format/plus-1.c -DWIDE -Wformat=0 negative addend (test for warnings, line 19)

Note that this patch is for gcc-4.9 and applies on top of the modified patch to enable -fstack-protector-strong by default in bug 1317307. I'll prepare a patch for gcc-4.8 for use in an SRU in a bit.

I've also added tests to lp:qa-regression-testing to ensure that passed command line arguments are honored over the default.