public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "roland.illig at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-99280-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99280

            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 difference,
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 message
on its own also increases the chances of typos, which makes the current
situation not perfect.  Maybe that can be improved.

                 reply	other threads:[~2021-02-26  0:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99280-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).