[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Calling yyerror with non-literal parameter triggers warning
From: |
August Karlstrom |
Subject: |
Calling yyerror with non-literal parameter triggers warning |
Date: |
Mon, 19 Aug 2019 22:05:27 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
When I use the default C compiler cc on macOS to compile a parser
generated by GNU Bison I get the following warning:
y.tab.c:3974:18: warning: format string is not a string literal
(potentially insecure) [-Wformat-security]
yyerror (yymsgp);
^~~~~~
y.tab.c:3974:18: note: treat the string as an argument to avoid this
yyerror (yymsgp);
^
"%s",
As the warning suggests, GNU Bison should instead generate the call
yyerror ("%s", yymsgp);
$ yacc --version
bison (GNU Bison) 3.3.2
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cc --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
-- August
- Calling yyerror with non-literal parameter triggers warning,
August Karlstrom <=