From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DA9393858C83; Sun, 11 Sep 2022 21:39:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA9393858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662932361; bh=Poi/N5NSIBeqh024g9igb1nlvMEbjlU/SM3izE8pNiY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HqXjpdn50WbvQRRl6aGBxBRoxeydiEony4cwhGHaLT2XJxiZOOu4TvYlHLQrWqKMB C/rz0kKNNNqkvstget/M1hovH0k23TykWOwd7mobTh0e6qwcv+1YAvocszFyitMXY5 HyIgVGFwe0J/bU5m5Ls7ug9UWqEFTyIOKb3rS5IM= From: "zfigura at codeweavers dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96367] bogus -Wformat-truncation in ILP32 Date: Sun, 11 Sep 2022 21:39:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: zfigura at codeweavers dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96367 Zebediah Figura changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zfigura at codeweavers dot= com --- Comment #3 from Zebediah Figura --- 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/syst= em.c#l3176 is yielding this warning: ../wine/dlls/ntdll/unix/system.c: In function =E2=80=98NtQuerySystemInforma= tion=E2=80=99: ../wine/dlls/ntdll/unix/system.c:3176:36: error: =E2=80=98%s=E2=80=99 direc= tive output between 0 and 2147483644 bytes may cause result to exceed =E2=80=98INT_MAX=E2=80=99 [-Werror=3Dformat-truncation=3D] 3176 | snprintf( info, size, "%s%c%s%c%s%c%s", version, 0, wine_bu= ild, 0, buf.sysname, 0, buf.release ); | ^~ ~~~~~~~= ~~~ ../wine/dlls/ntdll/unix/system.c:3176:9: note: =E2=80=98snprintf=E2=80=99 o= utput 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_bu= ild, 0, buf.sysname, 0, buf.release ); |=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~ 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 #include extern const char text[]; size_t func(char *buffer, size_t size) { size_t len =3D 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.=