From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A34C63858C53; Sat, 21 Jan 2023 11:12:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A34C63858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674299546; bh=r2kC2C9y/J5soHO1SpTqmium3+Y5cNv1NSWcAXYzX5Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iyxKfPMltPvAx5wz4HDwss5uuaZeikf7GyjZQBZ6u3S85tg5XVb/CricnZk9F8j/M XvlB4QdNseheg15QKXTMnIlzvVq836y/B6m2142qvItiKIhZmYXbHXh+AQY8jzuszK LM4ntSZc9s78Hvx/S8Z6DArk4lXIn/cLdoWP/e68= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108483] gcc warns about suspicious constructs for unevaluted ?: operand Date: Sat, 21 Jan 2023 11:12:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108483 --- Comment #6 from Jakub Jelinek --- Seems kernel has #define NULL ((void *)0), so if it is solely about allowing NULL, you could also #define ARRAY_SIZE_MAYBENULL(x) _Generic((x), void*: (BUG_ON(x), 0), defaul= t: \ sizeof(x)/sizeof(_Generic((x), void*: (x), default:*(x)))) or similar, so that uses of the macro on anything but arrays (not pointers)= or NULL pointer will be diagnosed with warning or runtime error (the latter ca= se for non-NULL void * typed pointers).=