[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Trying to disable error=format-security for clapack



On 05/16/2016 11:07 AM, Andreas Tille wrote:
> /build/clapack-3.2.1/F2CLIBS/libf2c/arithchk.c:125:2: error: format not a string literal and no format arguments [-Werror=format-security]
>   Cray1 = printf(emptyfmt) < 0 ? 0 : 4617762;

Hi Andreas,

you should have success with changing the type (insted of the value) of
emptyfmt, rather than disabling any warnings.

Right now it's "char *", which is legal C, but problematic, since
character literals are not allowed to be written to anyway and might
even be placed in read-only memory[1].  Just the type "readwrite pointer
to readwrite character" probably triggers the warning.

If you change it to "const char* const", the compiler is assured it's
never going to point to anything else and does not emit the warning.

Cheers,

- Danny

[1]: http://en.cppreference.com/w/c/language/string_literal
--- a/F2CLIBS/libf2c/arithchk.c
+++ b/F2CLIBS/libf2c/arithchk.c
@@ -110,7 +110,7 @@
 	return 0;
 	}
 
-char *emptyfmt = "";	/* avoid possible warning message with printf("") */
+const char * const emptyfmt = "";	/* avoid possible warning message with printf("") */
 
  static Akind *
 ccheck(void)

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: