diff mbox series

[3/3] locale: prevent maybe-uninitialized errors with -Os [BZ #19444]

Message ID 20180930155355.30989-1-Martin.Jansa@gmail.com
State New
Headers show
Series [PATCHv2] sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O [BZ #19444] | expand

Commit Message

Martin Jansa Sept. 30, 2018, 3:53 p.m. UTC
Fixes following error when building for aarch64 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;
|             ^~~~

        Partial fix for [BZ #23716]
        * locale/weight.h: Fix build with -Os.

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 ChangeLog       | 4 ++++
 locale/weight.h | 7 +++++++
 2 files changed, 11 insertions(+)

Comments

Martin Jansa Dec. 17, 2018, 6:22 p.m. UTC | #1
On Sun, Sep 30, 2018 at 03:53:55PM +0000, Martin Jansa wrote:
> Fixes following error when building for aarch64 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;
> |             ^~~~
> 
>         Partial fix for [BZ #23716]
>         * locale/weight.h: Fix build with -Os.
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>

I'm sorry for delay, I've just sent v6 for the first patch in this
series:
[PATCH 1/3] sysdeps/ieee754: prevent maybe-uninitialized errors
the 2nd one:
[PATCH 2/3] soft-fp: ignore maybe-uninitialized
was already merged, but I haven't noticed any feedback on this 3rd one
and it's still applicable in latest master.

Regards,

> ---
>  ChangeLog       | 4 ++++
>  locale/weight.h | 7 +++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 9cdf59c9ab..ef506309aa 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2018-09-30  Martin Jansa  <Martin.Jansa@gmail.com>
> +	Partial fix for [BZ #23716]
> +	* locale/weight.h: Fix build with -Os.
> +
>  2018-09-30  Martin Jansa  <Martin.Jansa@gmail.com>
>  	Partial fix for [BZ #23716]
>  	* sysdeps/ieee754/soft-fp/s_fdiv.c: Fix build with -O.
> diff --git a/locale/weight.h b/locale/weight.h
> index 6028d3595e..10bcea25e5 100644
> --- a/locale/weight.h
> +++ b/locale/weight.h
> @@ -28,7 +28,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.  */
> +  DIAG_PUSH_NEEDS_COMMENT;
> +  DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
>    int_fast32_t i = table[*(*cpp)++];
> +  DIAG_POP_NEEDS_COMMENT;
>    const unsigned char *cp;
>    const unsigned char *usrc;
>  
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/ChangeLog b/ChangeLog
index 9cdf59c9ab..ef506309aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@ 
+2018-09-30  Martin Jansa  <Martin.Jansa@gmail.com>
+	Partial fix for [BZ #23716]
+	* locale/weight.h: Fix build with -Os.
+
 2018-09-30  Martin Jansa  <Martin.Jansa@gmail.com>
 	Partial fix for [BZ #23716]
 	* sysdeps/ieee754/soft-fp/s_fdiv.c: Fix build with -O.
diff --git a/locale/weight.h b/locale/weight.h
index 6028d3595e..10bcea25e5 100644
--- a/locale/weight.h
+++ b/locale/weight.h
@@ -28,7 +28,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.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
   int_fast32_t i = table[*(*cpp)++];
+  DIAG_POP_NEEDS_COMMENT;
   const unsigned char *cp;
   const unsigned char *usrc;