https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104822
Bug ID: 104822
Summary: -Wscalar-storage-order warning for initialization from
NULL seems useless
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <stddef.h>
struct S {
int i;
} __attribute__((scalar_storage_order("big-endian")));
struct S *p = NULL;
This warns on x86:
sso.c:7:15: warning: initialization of ‘struct S *’ from pointer type ‘void *’
with incompatible scalar storage order [-Wscalar-storage-order]
7 | struct S *p = NULL;
| ^~~~
This doesn't seem useful. A null pointer cannot be derferenced, so there is no
chance of undefined behaviour caused by type punning struct T { int i; } as
struct S or vice versa.
Could the warning be suppressed static init of a pointer using NULL?