https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96367
Zebediah Figura <zfigura at codeweavers dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zfigura at codeweavers dot com --- Comment #3 from Zebediah Figura <zfigura at codeweavers dot com> --- I believe I'm running into this trying to compile Wine. Specifically, this snprintf statement: https://source.winehq.org/git/wine.git/blob/wine-7.17:/dlls/ntdll/unix/system.c#l3176 is yielding this warning: ../wine/dlls/ntdll/unix/system.c: In function ‘NtQuerySystemInformation’: ../wine/dlls/ntdll/unix/system.c:3176:36: error: ‘%s’ directive output between 0 and 2147483644 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-truncation=] 3176 | snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_build, 0, buf.sysname, 0, buf.release ); | ^~ ~~~~~~~~~~ ../wine/dlls/ntdll/unix/system.c:3176:9: note: ‘snprintf’ output between 8 and 2147483780 bytes into a destination of size 4294967295 3176 | snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_build, 0, buf.sysname, 0, buf.release ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ when compiled as 32-bit, using Wine's default flags (so notably -g -O2 -m32 -Wall). I also tried to reduce it into a simpler test case: #include <stdio.h> #include <string.h> extern const char text[]; size_t func(char *buffer, size_t size) { size_t len = strlen(text); snprintf(buffer, size, "text%s", text); return len; } which fails similarly with "gcc -m32 -O2 -Wall". Is there a way we can even work around this in Wine? I don't see an obvious one, especially with no clue why the bug is even happening.