On 1/28/22 16:27, Segher Boessenkool wrote: > On Fri, Jan 28, 2022 at 04:01:36PM +0100, Dumitru Ceara via Gcc-help wrote: >> void *l4data = p.l4_ofs != UINT16_MAX ? (char *) p.base_ + p.l4_ofs : NULL; >> struct hdr2 *h2 = l4data; >> >> memcpy(h2 + 1, &somedata[0], 6); > > l4data can be 0, and everything false apart from there on. > In general, yes, l4data can be 0, if p.l4_ofs == UINT16_MAX, which can only happen if pkt_bar() changed p.base_. But the compiler can't know that for sure and the warning makes it sound like it's a sure thing: "warning: ‘memcpy’ writing 6 bytes into a region of size 0 overflows the destination" In particular [0], we know for sure that l4data will not be NULL and we can avoid the warning with an extra assertion. It's just a bit inconvenient I guess. In any case, thanks for the quick response! Regards, Dumitru [0] https://github.com/dceara/ovn/commit/4796a6c480d5d2e35ec2e20ed0ae23ab787fa175