public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
@ 2022-04-06 14:19 arjun.is at lostca dot se
  2022-04-06 14:25 ` [Bug libc/29033] " arjun.is at lostca dot se
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: arjun.is at lostca dot se @ 2022-04-06 14:19 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

            Bug ID: 29033
           Summary: Calling 'error' on ppc64le can lead to spurious
                    compiler error with -Wnull-dereference -Werror
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: arjun.is at lostca dot se
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

misc/bits/error.h has:

/* If we know the function will never return make sure the compiler
   realizes that, too.  */
__extern_always_inline void
error (int __status, int __errnum, const char *__format, ...)
{ 
  if (__builtin_constant_p (__status) && __status != 0)
    __error_noreturn (__status, __errnum, __format, __va_arg_pack ());
  else
    __error_alias (__status, __errnum, __format, __va_arg_pack ());
}


But misc/bits/error-ldbl.h does not have this kind of handling.

Because of this, the following bit of code:

#include <error.h>
#include <stddef.h>
#include <stdlib.h>

struct S
{
  int i;
};

int
main (int argc, char **argv)
{
  struct S ss;
  struct S *s = argv[argc - 1] == NULL ? &ss : NULL;
  if (s == NULL)
    error (EXIT_FAILURE, 0, "frob");

  if (s->i == 0)
    return 1;

  return 0;
}

... when compiled with -Wnull-dereference leads to a warning/error:

$ gcc -Wnull-dereference -Werror -O2 -g test.c
w.c: In function ‘main’:
w.c:18:8: error: potential null pointer dereference [-Werror=null-dereference]
   18 |   if (s->i == 0)
      |       ~^~~
cc1: all warnings being treated as errors

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29033] Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
  2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
@ 2022-04-06 14:25 ` arjun.is at lostca dot se
  2022-04-06 14:59 ` mark at klomp dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: arjun.is at lostca dot se @ 2022-04-06 14:25 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

--- Comment #1 from Arjun Shankar <arjun.is at lostca dot se> ---
I should have mentioned that this is with GCC 12. I was able to reproduce this
on Fedora 36, e.g.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29033] Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
  2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
  2022-04-06 14:25 ` [Bug libc/29033] " arjun.is at lostca dot se
@ 2022-04-06 14:59 ` mark at klomp dot org
  2022-04-06 18:49 ` fweimer at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mark at klomp dot org @ 2022-04-06 14:59 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29033] Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
  2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
  2022-04-06 14:25 ` [Bug libc/29033] " arjun.is at lostca dot se
  2022-04-06 14:59 ` mark at klomp dot org
@ 2022-04-06 18:49 ` fweimer at redhat dot com
  2022-04-12 13:25 ` carlos at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2022-04-06 18:49 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-
                 CC|                            |fweimer at redhat dot com

--- Comment #2 from Florian Weimer <fweimer at redhat dot com> ---
It requires ieee128 mode, which Fedora 36 uses by default. It should be
reproducible with other GCC versions/distributions with -mabi=ieeelongdouble.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29033] Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
  2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
                   ` (2 preceding siblings ...)
  2022-04-06 18:49 ` fweimer at redhat dot com
@ 2022-04-12 13:25 ` carlos at redhat dot com
  2024-03-21 11:27 ` mmatti at linux dot vnet.ibm.com
  2024-03-21 11:48 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: carlos at redhat dot com @ 2022-04-12 13:25 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com,
                   |                            |tuliom at ascii dot art.br

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29033] Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
  2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
                   ` (3 preceding siblings ...)
  2022-04-12 13:25 ` carlos at redhat dot com
@ 2024-03-21 11:27 ` mmatti at linux dot vnet.ibm.com
  2024-03-21 11:48 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: mmatti at linux dot vnet.ibm.com @ 2024-03-21 11:27 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

Manjunath S Matti <mmatti at linux dot vnet.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmatti at linux dot vnet.ibm.com

--- Comment #3 from Manjunath S Matti <mmatti at linux dot vnet.ibm.com> ---
This was fixed by
https://sourceware.org/git/?p=glibc.git;a=patch;h=1a57ab0c923f269d1d7c29dfe4634c0ae66d69ac

Can we closed this bug

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/29033] Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror
  2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
                   ` (4 preceding siblings ...)
  2024-03-21 11:27 ` mmatti at linux dot vnet.ibm.com
@ 2024-03-21 11:48 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2024-03-21 11:48 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=29033

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.38
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #4 from Florian Weimer <fweimer at redhat dot com> ---
Fixed for 2.38 via:

commit 1a57ab0c923f269d1d7c29dfe4634c0ae66d69ac
Author: Sachin Monga <smonga@linux.ibm.com>
Date:   Wed May 10 13:59:21 2023 -0400

    Added Redirects to longdouble error functions [BZ #29033]

    This patch redirects the error functions to the appropriate
    longdouble variants which enables the compiler to optimize
    for the abi ieeelongdouble.

    Signed-off-by: Sachin Monga <smonga@linux.ibm.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2024-03-21 11:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 14:19 [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror arjun.is at lostca dot se
2022-04-06 14:25 ` [Bug libc/29033] " arjun.is at lostca dot se
2022-04-06 14:59 ` mark at klomp dot org
2022-04-06 18:49 ` fweimer at redhat dot com
2022-04-12 13:25 ` carlos at redhat dot com
2024-03-21 11:27 ` mmatti at linux dot vnet.ibm.com
2024-03-21 11:48 ` fweimer at redhat dot com

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