0015-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From bd2b87eaa2e99310f5439df95bea12a48dc978bf Mon Sep 17 00:00:00 2001
  2. From: Martin Jansa <martin.jansa@gmail.com>
  3. Date: Mon, 17 Dec 2018 21:36:18 +0000
  4. Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ
  5. #19444]
  6. Fixes following error when building for aarch64 with -Os:
  7. | In file included from strcoll_l.c:43:
  8. | strcoll_l.c: In function '__strcoll_l':
  9. | ../locale/weight.h:31:26: error: 'seq2.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  10. | int_fast32_t i = table[*(*cpp)++];
  11. | ^~~~~~~~~
  12. | strcoll_l.c:304:18: note: 'seq2.back_us' was declared here
  13. | coll_seq seq1, seq2;
  14. | ^~~~
  15. | In file included from strcoll_l.c:43:
  16. | ../locale/weight.h:31:26: error: 'seq1.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  17. | int_fast32_t i = table[*(*cpp)++];
  18. | ^~~~~~~~~
  19. | strcoll_l.c:304:12: note: 'seq1.back_us' was declared here
  20. | coll_seq seq1, seq2;
  21. | ^~~~
  22. Partial fix for [BZ #19444]
  23. * locale/weight.h: Fix build with -Os.
  24. Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/1014766]
  25. Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
  26. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  27. ---
  28. locale/weight.h | 7 +++++++
  29. 1 file changed, 7 insertions(+)
  30. diff --git a/locale/weight.h b/locale/weight.h
  31. index 8be2d220f8..4a4d5aa6b2 100644
  32. --- a/locale/weight.h
  33. +++ b/locale/weight.h
  34. @@ -27,7 +27,14 @@ findidx (const int32_t *table,
  35. const unsigned char *extra,
  36. const unsigned char **cpp, size_t len)
  37. {
  38. + /* With GCC 8 when compiling with -Os the compiler warns that
  39. + seq1.back_us and seq2.back_us might be used uninitialized.
  40. + This uninitialized use is impossible for the same reason
  41. + as described in comments in locale/weightwc.h. */
  42. + DIAG_PUSH_NEEDS_COMMENT;
  43. + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
  44. int32_t i = table[*(*cpp)++];
  45. + DIAG_POP_NEEDS_COMMENT;
  46. const unsigned char *cp;
  47. const unsigned char *usrc;