[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling yyerror with non-literal parameter triggers warning
From: |
uxio prego |
Subject: |
Re: Calling yyerror with non-literal parameter triggers warning |
Date: |
Mon, 19 Aug 2019 23:24:38 +0200 |
A small disclaimer:
- I suppose you are using a simple one-argument yyerror
correctly defined in line with the documentation suggests.
- I totally agree with your suggestion.
- As I use two-argument yyerror without hassle, I guess that could
mean you can work around “temporarily” by using a two-argument
yyerror.
Cheers,
> On 19 Aug 2019, at 23:19, uxio prego <address@hidden> wrote:
>
> Hi,
> been using Bison on macOS for a while,
> both default shipping, and via Homebrew.
> No big deal currently, for me, so I was surprised at your problem.
>
> Have you read this page?
> https://www.gnu.org/software/bison/manual/html_node/Error-Reporting.html
> Do you define the yyerror function as the doc tells?
> If so, how do you define it?
>
> I’m just another user like you, so this is not official answer.
>
> Cheers,
>
>> On 19 Aug 2019, at 22:05, August Karlstrom <address@hidden> wrote:
>>
>> 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
>>
>