[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
It fails to build with -O0
From: |
Yuri Kanivetsky |
Subject: |
It fails to build with -O0 |
Date: |
Thu, 20 Apr 2023 04:19:16 +0300 |
Hi,
I tried to build it with -O0 (which looks like the best level for
debugging to me), and with it it fails:
$ docker run --rm -it alpine:3.17
# / apk add build-base git autoconf automake gettext-dev texinfo perl
rsync wget coreutils
# / git clone https://git.savannah.gnu.org/git/sed.git
# / cd sed
# /sed ./bootstrap
# /sed ./configure CFLAGS='-O0 -gdwarf-4 -g3'
# /sed make V=1
...
gcc -DHAVE_CONFIG_H -I. -I. -I./lib -I./lib -I./sed
-DLOCALEDIR=\"/usr/local/share/locale\" -fanalyzer -fno-common -Wall
-Warith-conversion -Wbad-function-cast -Wcast-align=strict -Wdate-time
-Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches
-Wduplicated-cond -Wextra -Wformat-signedness -Winit-self -Winline
-Winvalid-pch -Wlogical-op -Wmissing-declarations
-Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs
-Wnull-dereference -Wold-style-definition -Wopenmp-simd
-Woverlength-strings -Wpacked -Wpointer-arith -Wshadow
-Wstack-protector -Wstrict-overflow -Wstrict-prototypes
-Wsuggest-attribute=cold -Wsuggest-attribute=const
-Wsuggest-attribute=format -Wsuggest-attribute=malloc
-Wsuggest-attribute=noreturn -Wsuggest-attribute=pure
-Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand
-Wtrampolines -Wuninitialized -Wunknown-pragmas
-Wunsafe-loop-optimizations -Wunused-macros -Wvariadic-macros
-Wvector-operation-performance -Wvla -Wwrite-strings -Warray-bounds=2
-Wattribute-alias=2 -Wbidi-chars=any,ucn -Wformat-overflow=2
-Wformat=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5
-Wshift-overflow=2 -Wuse-after-free=3 -Wunused-const-variable=2
-Wvla-larger-than=4031 -Wno-analyzer-malloc-leak -Wno-sign-compare
-fdiagnostics-show-option -funit-at-a-time -Werror -g -O0 -MT
sed/sed-utils.o -MD -MP -MF sed/.deps/sed-utils.Tpo -c -o
sed/sed-utils.o `test -f 'sed/utils.c' || echo './'`sed/utils.c
sed/utils.c: In function 'ck_getdelim':
sed/utils.c:266:10: error: use of uninitialized value 'result'
[CWE-457] [-Werror=analyzer-use-of-uninitialized-value]
266 | return result;
| ^~~~~~
'ck_getdelim': events 1-6
|
| 253 | ssize_t result;
| | ^~~~~~
| | |
| | (1) region created on stack here
|......
| 257 | if (!error)
| | ~
| | |
| | (2) following 'false' branch...
|......
| 263 | if (error)
| | ~
| | |
| | (3) ...to here
| | (4) following 'false' branch (when 'error == 0')...
|......
| 266 | return result;
| | ~~~~~~
| | |
| | (5) ...to here
| | (6) use of uninitialized value 'result' here
|
cc1: all warnings being treated as errors
make[2]: *** [Makefile:5006: sed/sed-utils.o] Error 1
make[2]: Leaving directory '/sed'
make[1]: *** [Makefile:5230: all-recursive] Error 1
make[1]: Leaving directory '/sed'
make: *** [Makefile:2789: all] Error 2
I'm passing -gdwarf-4 because of the gdb bug:
https://stackoverflow.com/questions/75631484/gdb-doesnt-support-dwarf-5-macro-sections/75665481#75665481
The function it complains about:
https://git.savannah.gnu.org/cgit/sed.git/tree/sed/utils.c?id=8c802c5078855798ece5d0859e2c779fa059954a#n250
Apparently the analyzer is mistaken, because it doesn't know that
panic() terminates the program.
Probably a minor issue, but if there's a simple solution, you might
want to fix it.
The workaround:
./configure CFLAGS='-O0 -gdwarf-4 -g3 -Wno-analyzer-use-of-uninitialized-value'
Regards,
Yuri
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- It fails to build with -O0,
Yuri Kanivetsky <=