unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix maybe-uninitialized error on powerpc
@ 2020-01-09 18:27 Matheus Castanho
  2020-01-09 18:48 ` Joseph Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Matheus Castanho @ 2020-01-09 18:27 UTC (permalink / raw)
  To: libc-alpha

The build has been failing on powerpc64le-linux-gnu with GCC 10
due to a maybe-uninitialized error:

../sysdeps/ieee754/dbl-64/mpa.c:875:6: error: ‘w.e’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  875 |   EY -= EX;
      |      ^~

This commits adds proper initialization to avoid it.

Tested on powerpc64le.
---
 sysdeps/ieee754/dbl-64/mpa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c
index 3bb8bff90d..8ad0fc7535 100644
--- a/sysdeps/ieee754/dbl-64/mpa.c
+++ b/sysdeps/ieee754/dbl-64/mpa.c
@@ -895,6 +895,7 @@ SECTION
 __dvd (const mp_no *x, const mp_no *y, mp_no *z, int p)
 {
   mp_no w;
+  w.e = 0;
 
   if (X[0] == 0)
     Z[0] = 0;
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix maybe-uninitialized error on powerpc
  2020-01-09 18:27 [PATCH] Fix maybe-uninitialized error on powerpc Matheus Castanho
@ 2020-01-09 18:48 ` Joseph Myers
  2020-01-13 13:47   ` Matheus Castanho
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Myers @ 2020-01-09 18:48 UTC (permalink / raw)
  To: Matheus Castanho; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 1039 bytes --]

On Thu, 9 Jan 2020, Matheus Castanho wrote:

> The build has been failing on powerpc64le-linux-gnu with GCC 10
> due to a maybe-uninitialized error:
> 
> ../sysdeps/ieee754/dbl-64/mpa.c:875:6: error: ‘w.e’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>   875 |   EY -= EX;
>       |      ^~
> 
> This commits adds proper initialization to avoid it.

glibc practice is not to add such initializations just to avoid warnings, 
if the warnings are false positives (rather, DIAG_* macros with 
appropriate comments, or __builtin_unreachable, are used instead).

I think what's going on here is that __dbl_mp may not set the exponent of 
a returned 0 value, but in fact a returned 0 value is impossible in the 
case where GCC is reporting uninitialized data.  If you agree with that 
analysis, does putting

  if (t == 0)
    __builtin_unreachable ();

(with a comment justifying *why* t cannot be 0), just before the __dbl_mp 
call in __inv, help with the warning?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix maybe-uninitialized error on powerpc
  2020-01-09 18:48 ` Joseph Myers
@ 2020-01-13 13:47   ` Matheus Castanho
  0 siblings, 0 replies; 3+ messages in thread
From: Matheus Castanho @ 2020-01-13 13:47 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On 1/9/20 3:48 PM, Joseph Myers wrote:
> On Thu, 9 Jan 2020, Matheus Castanho wrote:
> 
>> The build has been failing on powerpc64le-linux-gnu with GCC 10
>> due to a maybe-uninitialized error:
>>
>> ../sysdeps/ieee754/dbl-64/mpa.c:875:6: error: ‘w.e’ may be used
>> uninitialized in this function [-Werror=maybe-uninitialized]
>>   875 |   EY -= EX;
>>       |      ^~
>>
>> This commits adds proper initialization to avoid it.
> 
> glibc practice is not to add such initializations just to avoid warnings, 
> if the warnings are false positives (rather, DIAG_* macros with 
> appropriate comments, or __builtin_unreachable, are used instead).
> 
> I think what's going on here is that __dbl_mp may not set the exponent of 
> a returned 0 value, but in fact a returned 0 value is impossible in the 
> case where GCC is reporting uninitialized data.  If you agree with that 
> analysis, does putting
> 
>   if (t == 0)
>     __builtin_unreachable ();
> 
> (with a comment justifying *why* t cannot be 0), just before the __dbl_mp 
> call in __inv, help with the warning?

Thanks for the help, that seems the problem indeed, and this check does
solve it.

I'll do this instead (with the justification comment) and send a new
patch later.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-13 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09 18:27 [PATCH] Fix maybe-uninitialized error on powerpc Matheus Castanho
2020-01-09 18:48 ` Joseph Myers
2020-01-13 13:47   ` Matheus Castanho

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).