Bug 56048 - -Werror=format=2 does not work
Summary: -Werror=format=2 does not work
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2013-01-19 19:20 UTC by Henrique
Modified: 2021-09-16 21:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-01-21 00:00:00


Attachments
format-warning.c (97 bytes, text/x-csrc)
2013-01-19 19:20 UTC, Henrique
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Henrique 2013-01-19 19:20:19 UTC
Created attachment 29222 [details]
format-warning.c

format-warning.c:
#include <stdio.h>

int main(void)
{
	const char *s = "%s\n";
	printf(s, "abcd");
	return 0;
}

$ gcc -Wall -Werror -Werror=format=2 -o format-warning format-warning.c (no error)

$ gcc -Wall -Werror -Werror=format -Werror=format-nonliteral -Werror=format-security -Werror=format-y2k -o format-warning format-warning.c 
format-warning.c: Na função ‘main’:
format-warning.c:6:2: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
Comment 1 Manuel López-Ibáñez 2013-01-21 11:26:52 UTC
I think this may be fixed in GCC 4.8, but I don't have a recently build GCC at hand to test it.
Comment 2 Manuel López-Ibáñez 2013-01-21 12:31:54 UTC
(In reply to comment #1)
> I think this may be fixed in GCC 4.8, but I don't have a recently build GCC at
> hand to test it.

Actually, it is not. opts.c:control_warning_as_error doesn't handle options with joined arguments, the argument is ignored. Extra code would need to be added to check that the option is joined, that it has an argument, read the argument and pass the correct value to control_warning. Then, it should work.