public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org, Martin Jansa <Martin.Jansa@gmail.com>
Subject: Re: [PATCH 1/6] locale: prevent maybe-uninitialized errors with -Os [BZ #19444]
Date: Wed, 5 Oct 2022 09:39:23 -0400	[thread overview]
Message-ID: <Yz2JCxu/4e5z8qCM@fedora> (raw)
In-Reply-To: <20220921135108.3324737-2-adhemerval.zanella@linaro.org>

On Wed, Sep 21, 2022 at 10:51:03AM -0300, Adhemerval Zanella via Libc-alpha wrote:
> From: Martin Jansa <Martin.Jansa@gmail.com>
> 
> Fixes following error when building  with -Os:
> | In file included from strcoll_l.c:43:
> | strcoll_l.c: In function '__strcoll_l':
> | ../locale/weight.h:31:26: error: 'seq2.back_us' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> |    int_fast32_t i = table[*(*cpp)++];
> |                           ^~~~~~~~~
> | strcoll_l.c:304:18: note: 'seq2.back_us' was declared here
> |    coll_seq seq1, seq2;
> |                   ^~~~
> | In file included from strcoll_l.c:43:
> | ../locale/weight.h:31:26: error: 'seq1.back_us' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> |    int_fast32_t i = table[*(*cpp)++];
> |                           ^~~~~~~~~
> | strcoll_l.c:304:12: note: 'seq1.back_us' was declared here
> |    coll_seq seq1, seq2;
> |             ^~~~

LGTM.

No regresions on x86_64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  locale/weight.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/locale/weight.h b/locale/weight.h
> index 8be2d220f8..4a4d5aa6b2 100644
> --- a/locale/weight.h
> +++ b/locale/weight.h
> @@ -27,7 +27,14 @@ findidx (const int32_t *table,
>  	 const unsigned char *extra,
>  	 const unsigned char **cpp, size_t len)
>  {
> +  /* With GCC 8 when compiling with -Os the compiler warns that
> +     seq1.back_us and seq2.back_us might be used uninitialized.
> +     This uninitialized use is impossible for the same reason
> +     as described in comments in locale/weightwc.h.  */

OK. Agreed.

> +  DIAG_PUSH_NEEDS_COMMENT;
> +  DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
>    int32_t i = table[*(*cpp)++];
> +  DIAG_POP_NEEDS_COMMENT;
>    const unsigned char *cp;
>    const unsigned char *usrc;
>  
> -- 
> 2.34.1
> 


  reply	other threads:[~2022-10-05 13:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 13:51 [PATCH 0/6] Fix -Os build Adhemerval Zanella
2022-09-21 13:51 ` [PATCH 1/6] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] Adhemerval Zanella
2022-10-05 13:39   ` Carlos O'Donell [this message]
2022-09-21 13:51 ` [PATCH 2/6] posix: Suppress -Os warnings on fnmatch Adhemerval Zanella
2022-10-05 13:47   ` Carlos O'Donell
2022-10-05 20:01     ` Paul Eggert
2022-09-21 13:51 ` [PATCH 3/6] posix: Suppress -Os may be used uninitialized warnings on regexec Adhemerval Zanella
2022-10-05 13:49   ` Carlos O'Donell
2022-09-21 13:51 ` [PATCH 4/6] rt: Initialize mq_send input on tst-mqueue{5,6} Adhemerval Zanella
2022-10-05 13:51   ` Carlos O'Donell
2022-09-21 13:51 ` [PATCH 5/6] sunrpc: Suppress GCC -Os warning on user2netname Adhemerval Zanella
2022-10-05 13:52   ` Carlos O'Donell
2022-09-21 13:51 ` [PATCH 6/6] x86: Fix -Os build (BZ #29576) Adhemerval Zanella
2022-10-05 14:10   ` Carlos O'Donell
2022-10-05 17:21     ` H.J. Lu
2022-10-05 17:38       ` Adhemerval Zanella Netto
2022-10-05 18:06         ` H.J. Lu
2022-10-05 20:43           ` Adhemerval Zanella Netto
2022-10-05 21:27             ` H.J. Lu
2022-10-05 13:40 ` [PATCH 0/6] Fix -Os build Carlos O'Donell

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=Yz2JCxu/4e5z8qCM@fedora \
    --to=carlos@redhat.com \
    --cc=Martin.Jansa@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.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).