public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "arjun.is at lostca dot se" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/29033] New: Calling 'error' on ppc64le can lead to spurious compiler error with -Wnull-dereference -Werror Date: Wed, 06 Apr 2022 14:19:59 +0000 [thread overview] Message-ID: <bug-29033-131@http.sourceware.org/bugzilla/> (raw) 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.
next reply other threads:[~2022-04-06 14:19 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-06 14:19 arjun.is at lostca dot se [this message] 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
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=bug-29033-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@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: linkBe 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).