[Bug c/106537] New: GCC doesn't support -W[no-]compare-distinct-pointer-types
jose.marchesi at oracle dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 5 12:39:11 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106537
Bug ID: 106537
Summary: GCC doesn't support
-W[no-]compare-distinct-pointer-types
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jose.marchesi at oracle dot com
Target Milestone: ---
GCC emits pedwarns unconditionally when comparing pointers of different types,
for example:
int xdp_context (struct xdp_md *xdp)
{
void *data = (void *)(long)xdp->data;
__u32 *metadata = (void *)(long)xdp->data_meta;
__u32 ret;
if (metadata + 1 > data)
return 0;
return 1;
}
/home/jemarch/foo.c: In function ‘xdp_context’:
/home/jemarch/foo.c:15:20: warning: comparison of distinct pointer types
lacks a cast
15 | if (metadata + 1 > data)
| ^
LLVM supports an option -W[no-]compare-distinct-pointer-types that can be used
in order to enable or disable the emission of such warnings. It is enabled by
default.
This option is used in the kernel source tree for some BPF programs.
I already got a patch for this.
More information about the Gcc-bugs
mailing list