This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/79082] -Wformat-truncation inconsistent behaviour
- From: "sylvestre at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jan 2017 10:57:26 +0000
- Subject: [Bug c/79082] -Wformat-truncation inconsistent behaviour
- Auto-submitted: auto-generated
- References: <bug-79082-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79082
Sylvestre Ledru <sylvestre at debian dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sylvestre at debian dot org
--- Comment #11 from Sylvestre Ledru <sylvestre at debian dot org> ---
Other testcase:
---
#include <stdio.h>
#include <stdint.h>
int main() {
char* buf = new char[10];
uint8_t data = 255;
printf("%.2x\n", data); // just print data
snprintf(&buf[0], 2, "%.2x", data);
return 0;
}
---
foo.c:7:13: note: format output 3 bytes into a destination of size 2
snprintf(&buf[0], 2, "%.2x", data);
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
---