From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 154C93857C61; Fri, 26 Feb 2021 00:19:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 154C93857C61 From: "roland.illig at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99280] New: argument to warning_n must be a string literal Date: Fri, 26 Feb 2021 00:19:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: roland.illig at gmx dot de 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2021 00:19:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99280 Bug ID: 99280 Summary: argument to warning_n must be a string literal Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: roland.illig at gmx dot de Target Milestone: --- builtins.c says (in condensed form): > warning_n( > loc, OPT_Wstringop_overread, tree_to_uhwi(range[0]), > (maybe > ? G_("%K%qD may reade %E byte from a region of size %E") > : G_("%K%qD reading %E byte from a region of size %E")), > (maybe > ? G_("%K%qD may read %E bytes from a region of size %E") > : G_("%K%qD reading %E bytes from a region of size %E")), > exp, func, range[0], size); The format strings to warning_n are not string literals. Therefore xgettext does not recognize them as plural messages, and they show up in Poedit and other editors as ordinary singular messages. Marking them with G_ is a workaround, but that works only halfway. The message is indeed translated,= but not in the correct plural form. For German and French this does not matter since their plural forms for n >= 0 are the same as in English. But for Polish or Russian it makes a differenc= e, and the Russian translation is actively maintained. Maybe it is possible to teach xgettext to correctly analyze not only string literals but also the expression 'identifier ? "literal1" : "literal2". If that is not possible, the (only?) correct solution may be to duplicate even more of this code. That would mean more concentrated work for both the programmers and the translators since it is really difficult to avoid copy-and-paste mistakes with all these similar messages. Typing each messa= ge on its own also increases the chances of typos, which makes the current situation not perfect. Maybe that can be improved.=