From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C04AD385840C; Wed, 6 Apr 2022 14:19:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C04AD385840C From: "arjun.is at lostca dot se" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arjun.is at lostca dot se X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 14:20:00 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29033 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, ...) {=20 if (__builtin_constant_p (__status) && __status !=3D 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 #include #include struct S { int i; }; int main (int argc, char **argv) { struct S ss; struct S *s =3D argv[argc - 1] =3D=3D NULL ? &ss : NULL; if (s =3D=3D NULL) error (EXIT_FAILURE, 0, "frob"); if (s->i =3D=3D 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 =E2=80=98main=E2=80=99: w.c:18:8: error: potential null pointer dereference [-Werror=3Dnull-derefer= ence] 18 | if (s->i =3D=3D 0) | ~^~~ cc1: all warnings being treated as errors --=20 You are receiving this mail because: You are on the CC list for the bug.=