https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109542
Bug ID: 109542 Summary: bad detection of null dereferance cause ud2a in valid inline function code Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: amos.maimon at sap dot com Target Milestone: --- Created attachment 54881 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54881&action=edit snip code that reproduce the issue that decribe above There is a bug in the detection of null dereferance - and user code change to UD2A. This happened when the function picked to be inline. How to reproduce: 1. download the attached code snip. 2. compile with the following params: gcc -Wall -Werror -Wno-packed-not-aligned -Wno-address-of-packed-member -Wno-multichar -Wno-unused -fno-strict-aliasing -fno-optimize-sibling-calls -mno-sse -fno-omit-frame-pointer -g -finline-limit=6000 -mcmodel=large -ffreestanding -mno-red-zone -O2 test.c 3. with objdump you can see that the line : *(p + 0xffffe) = 0xfc; compile to : 1044: c6 04 25 fe ff 0f 00 movb $0x0,0xffffe 104b: 00 104c: 0f 0b ud2 While if instead p you will use local parameter (define SIMPLE_WRITE and recompile) it will keep user code as expected: 1044: c6 04 25 fe ff 0f 00 movb $0xfc,0xffffe 104b: fc Note that the problam will not occur if -fno-delete-null-pointer-checks will be added to the compilation parameters.