FTBFS if "-Werror=format-security" flag is used

John Reiser jreiser at BitWagon.com
Tue Dec 10 17:44:20 UTC 2013


> 1. There are legitimate use-cases where GCC's assumption does not hold, .e.g.:
>
> #include <stdio.h>
>
> void foo( int a )
> {
>   char hello0[] = "hello0";

foo.c line 5: warning: 'const' omitted

>   char hello1[] = "hello1";

foo.c line 6: warning: 'const' omitted

>
>   char *ptr;

foo.c line 8: warning: 'const' omitted

>
>   switch (a % 2) {
>   case 0: ptr = hello0;
>     break;
>   case 1: ptr = hello1;
>     break;
>   }
>
>   printf( ptr );
> }
>
> => The warning GCC issues is plain wrong.
>
> => -Werror=format-security removes the functionality of assigning pointers to format strings even if they are constant.

The example does not support this argument because the example omitted the 'const' (three places.)
gcc-4.[89] isn't advanced enough to distinguish, but the example does not match the argument.



More information about the devel mailing list