[Bug middle-end/82123] New: [7 regression] spurious -Wformat-overflow warning for converted vars
arnd at linaro dot org
gcc-bugzilla@gcc.gnu.org
Wed Sep 6 15:41:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82123
Bug ID: 82123
Summary: [7 regression] spurious -Wformat-overflow warning for
converted vars
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: arnd at linaro dot org
Target Milestone: ---
This one seems to be related to pr77721 and pr81483. The first however only
happens with -Wformat-overflow=2, and the second one has no type conversion, so
I'm opening a separate pr for this one. Reproduced with gcc-7.1.1 and gcc-8.0.0
(r251692).
$ x86_64-linux-gcc-8.0.0 -c gpiolib-acpi.c -O2 -Wformat-overflow=1
gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt':
gpiolib-acpi.c:7:28: warning: '%02X' directive writing between 2 and 4 bytes
into a region of size 3 [-Wformat-overflow=]
__builtin_sprintf(name, "%02X", pin);
^~~~
gpiolib-acpi.c:7:27: note: directive argument in the range [0, 65535]
__builtin_sprintf(name, "%02X", pin);
^~~~~~
gpiolib-acpi.c:7:3: note: '__builtin_sprintf' output between 3 and 5 bytes into
a destination of size 3
__builtin_sprintf(name, "%02X", pin);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8<----
void acpi_gpiochip_request_interrupt(unsigned short s)
{
char name[3];
unsigned int pin = s;
if (pin <= 255)
__builtin_sprintf(name, "%02X", pin);
}
More information about the Gcc-bugs
mailing list