https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104119
Bug ID: 104119
Summary: Wrong -Werror=format-overflow= since
r12-5014-g6b8b959675a3e14c
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: aldyh at gcc dot gnu.org, amacleod at redhat dot com
Target Milestone: ---
Since the revision I see (reduced from multipath-tools package)
$ cat devmapper.i
struct {
char id[8];
int needs_paths_uevent;
} *p;
void dm_addmap_create()
{
char *str = __builtin_malloc((sizeof("mpath-") - 1) + __builtin_strlen(p->id)
+ 10);
__builtin_sprintf(str, "mpath-%s", p->id);
}
$ gcc devmapper.i -c -m32 -O2 -Werror=format-overflow
devmapper.i: In function ‘dm_addmap_create’:
devmapper.i:9:33: error: ‘%s’ directive writing up to 2147483644 bytes into a
region of size 2147483641 [-Werror=format-overflow=]
9 | __builtin_sprintf(str, "mpath-%s", p->id);
| ^~
devmapper.i:9:3: note: ‘__builtin_sprintf’ output between 7 and 2147483651
bytes into a destination of size 2147483647
9 | __builtin_sprintf(str, "mpath-%s", p->id);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
Note one needs -m32!