https://sourceware.org/bugzilla/show_bug.cgi?id=32527
Bug ID: 32527 Summary: elfutils build warnings when building GCC -O3 Product: elfutils Version: unspecified Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: general Assignee: unassigned at sourceware dot org Reporter: phi.debian at gmail dot com CC: elfutils-devel at sourceware dot org Target Milestone: --- Hi I used the component 'General' because the component 'libcpu' don't exist in the selection list. When building on ubuntu 24.04 GCC (and g++) 14.2.0 with options -m64 -O3 -g1 on x86_64 and s390, we got warnings, yet make check show no errors, this is why I marked this as 'enhancement' The warnings occurs when building libcpu/i386_lex.o from i386_lex.l. ------------------------- In function ‘i386__init_buffer’, inlined from ‘i386_restart’ at i386_lex.c:1699:2: i386_lex.c:1815:25: warning: potential null pointer dereference [-Wnull-dereference] 1815 | b->yy_bs_column = 0; | ~~~~~~~~~~~~~~~~^~~ i386_lex.c:1814:25: warning: potential null pointer dereference [-Wnull-dereference] ... ------------------------- Indeed this is not critical at all, but I try to build with no warnings. The warning is due to the flex skeleton for lexer that use a pointer from malloc() that could be NULL, even though this never happen except may be on stressed systems, it is still possible, the punishment would be a core dump though. This occurs only with gcc -O3, -O2 don't show this, clang never show it. I think gcc -O3 is right though, it do more inlining and discover the potentially faulty unchecked malloc (we use the std def yymalloc == malloc) Since we have little chance to get the lexer skeleton fixed from flex team, a possible workaround is to add the option -Wno-null-dereference in the file elfutils/libcpu/Makefile.am like this i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \ -Wno-implicit-fallthrough -Wno-null-dereference By doing so, the warning disapear, we don't jeopardise anything, and it is cleaner for the one who wants to build the perf path with no warnings. Cheers, Phi -- You are receiving this mail because: You are on the CC list for the bug.