From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4F5173858D3C; Sun, 4 Feb 2024 06:15:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F5173858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707027336; bh=VEd0sgwDK6KAftLCcD6C7ctzKyv/SfpjXN1jU423Izg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f+6iBZ1Uj/56Ti1OsY7Sn4KMLjqRtqjKJ8x2uTZcuMK6AjIUBx6KBI4bcrS+6q4uL nkJTOFLYDcDJ5ujRTQWPRMwvSBYW+ErD0SkphtgsdOcQM0V1H41NqduOboFSZg0G9b sQ92TF+0Pti0MXogUsydixZOBWMiSbp2aJtnF2MQ= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyB0cmVlLW9wdGltaXphdGlvbi8xMTM3NTJdIFsxNCBSZWdy?= =?UTF-8?B?ZXNzaW9uXSB3YXJuaW5nOiDigJglc+KAmSBkaXJlY3RpdmUgd3JpdGluZyB1?= =?UTF-8?B?cCB0byAxMDIxOCBieXRlcyBpbnRvIGEgcmVnaW9uIG9mIHNpemUgYmV0d2Vl?= =?UTF-8?B?biAwIGFuZCAxMDI0MCBbLVdmb3JtYXQtb3ZlcmZsb3c9XQ==?= Date: Sun, 04 Feb 2024 06:15:35 +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: 14.0 X-Bugzilla-Keywords: diagnostic, needs-reduction X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail 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: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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=3D113752 --- Comment #2 from H.J. Lu --- [hjl@gnu-skx-1 gcc]$ cat /tmp/foo.i char a[10256]; char b; char *c, *g; int d, e, f; int sprintf(char *, char *, ...); unsigned long strlen(char *); int h(char *j) { if (strlen(j) + strlen(c) + strlen(g) + 32 > 10256) return 0; sprintf(a, "%s:%s:%d:%d:%d:%c:%s\n", j, c, d, e, f, b, g); return 1; } void i() { h("wctype"); } [hjl@gnu-skx-1 gcc]$ ./xgcc -B./ -O3 -Wall -S /tmp/foo.i /tmp/foo.i: In function ?i?: /tmp/foo.i:10:33: warning: ?%s? directive writing up to 10218 bytes into a region of size between 0 and 10240 [-Wformat-overflow=3D] 10 | sprintf(a, "%s:%s:%d:%d:%d:%c:%s\n", j, c, d, e, f, b, g); | ^~ In function ?h?, inlined from ?i? at /tmp/foo.i:13:12: /tmp/foo.i:10:3: note: ?sprintf? output between 18 and 20484 bytes into a destination of size 10256 10 | sprintf(a, "%s:%s:%d:%d:%d:%c:%s\n", j, c, d, e, f, b, g); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [hjl@gnu-skx-1 gcc]$=