From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8EC013858D20; Sun, 28 Apr 2024 09:06:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EC013858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714295184; bh=53do0YJUk0B5R/QB0uG1ysLkyRMu3AVUMaMK/2uc310=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kotn+NhIj/7ZFAPHBU+8OFMOJM902w1sk38a5JWM32VcGeNDXhEfWMjBwP+lT3t64 W0MhwaJqBjgI68txnYSWIWLvfvgRpherp08dNzx/U9Vligw5slUFeOzTO6wvHM16Qr 2/r2NlFc2yIm/i/DJiwkpFZLLlvL9CG3bAAn9ctU= From: "bruno at clisp dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114876] -fprintf-return-value mishandles %lc with a '\0' argument. Date: Sun, 28 Apr 2024 09:06:23 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot org X-Bugzilla-Status: UNCONFIRMED 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=3D114876 Bruno Haible changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bruno at clisp dot org --- Comment #1 from Bruno Haible --- What does *printf of %lc with a (wint_t) '\0' argument do? Note that the published POSIX:2018 still has a wrong description: Its description requires *printf to produce 0 characters. This was wrong in ISO C as well. It has been corrected in ISO C 23 =C2=A7 7= .23.6.1, in the meeting from 2023-06-20 to 2023-06-23. See https://www.open-std.org/JTC1/sc22/wg14/www/docs/n3167.pdf section GB-141 = page 23, 24. The decision ("option 1") is detailed in https://www.open-std.org/JTC1/sc22/wg14/www/docs/n3148.doc row GB-141 page = 34, 35: "Option 1 (require a NUL) - change the text to: If an l length modifier is present, the wint_t argument is converted as if by a call to the wcrtomb function with a pointer to storage of at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t, and an initial shift state." This description requires *printf to produce 1 NUL character. Then, the Austin Group followed suit and, through https://austingroupbugs.net/view.php?id=3D1647 , decided that POSIX will us= e the same definition: "If an l (ell) qualifier is present, the wint_t argument shall be convert= ed to a multi-byte sequence as if by a call to wcrtomb( ) with the wint_t argument converted to wchar_t and an initial shift state, and the resulting bytes written." This aligns the POSIX behaviour with what glibc was doing all the time, nam= ely to produce 1 NUL character.=