From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 248783858291; Tue, 9 May 2023 12:44:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 248783858291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683636288; bh=U6yc29XzQyOSCWYahvcBnuBHtRRAFB0XP2lZ1XHxFBM=; h=From:To:Subject:Date:From; b=JPxJRd3SwGFaHDHjFiGGA7eJgJW3PAKteZvTlXKltTF4mMTEsowXQtoRZRLGWBzuf 2lE4nnQC8Mjb48nrtWbaj3ZcWQztCVb9TWO5lKes+MXvRXiE9vduwZdfVzIr7SzxcG mxrQB0rMl78XRaINig/Pc8J8QO18RdJMxnx8HLb4= From: "alex at zrythm dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109789] New: analyzer-use-of-uninitialized-value false positive Date: Tue, 09 May 2023 12:44:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alex at zrythm dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109789 Bug ID: 109789 Summary: analyzer-use-of-uninitialized-value false positive Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alex at zrythm dot org Target Milestone: --- Created attachment 55028 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55028&action=3Dedit gcc invocation output showing the error The first error in the attached gcc output is a false positive because the `tmp_l` float array is initialized for its whole size right after it is declared, and the same size is passed to the function where the error occur= s. That function loops over the float array and calls `fabsf` causing this analyzer error. This is essentially the code: ```c float tmp_l[nframes]; // this is the array for (nframes_t i =3D 0; i < nframes; i++) { tmp_l[i] =3D P_MASTER_TRACK->channel->stereo_out->l->buf[i]; } float max_amp =3D dsp_abs_max (tmp_l, nframes); // this is the function cal= led ``` The function code: ```c static inline float dsp_abs_max (float * buf, size_t size) { float ret =3D 1e-20f; for (size_t i =3D 0; i < size; i++) { if (fabsf (buf[i]) > ret) { ret =3D fabsf (buf[i]); } } return ret; ``` As you can see, `tmp_l` is initialized for its whole size, which is then pa= ssed to the function above to loop over it, so the analyzer saying the value is uninitialized is wrong. Below is the gcc invocation command used: ``` LANG=3DC gcc -v -save-temps -Isrc/libzrythm-lib.so.p -Isrc -I../src -I. -I.. -Iinc -I../inc -Iext -I../ext -Iext/kissfft -I../ext/kissfft -Iext/midilib -I../ext/midilib -Iext/whereami -I../ext/whereami -Iext/weakjack -I../ext/weakjack -I../inc/plugins/lv2 -Isubprojects/libadwaita/src -I../subprojects/libadwaita/src -Isubprojects/gtk4 -I../subprojects/gtk4 -Isubprojects/gtk4/gtk -I../subprojects/gtk4/gtk -Isubprojects/pango-1.50.6 -I../subprojects/pango-1.50.6 -Isubprojects/pango-1.50.6/pango -I../subprojects/pango-1.50.6/pango -Isubprojects/gtk4/gdk/x11 -I../subprojects/gtk4/gdk/x11 -Isubprojects/gtk4/gdk -I../subprojects/gtk4/= gdk -Isubprojects/libpanel/src -I../subprojects/libpanel/src -Isubprojects/libp= anel -I../subprojects/libpanel -Isubprojects/libsndfile-1.1.0 -I../subprojects/libsndfile-1.1.0 -I../subprojects/libsndfile-1.1.0/src -I../subprojects/libcyaml/include -Isubprojects/libaudec -I../subprojects/libaudec -Isubprojects/libaudec/inc -I../subprojects/libaudec/inc -Isubprojects/rtaudio -I../subprojects/rtaudio -I../subprojects/rtmidi/rtmidi -I../subprojects/zstd-1.4.5/lib -I../subprojects/zstd-1.4.5/lib/common -I../subprojects/zstd-1.4.5/lib/comp= ress -I../subprojects/zstd-1.4.5/lib/decompress -I../subprojects/zstd-1.4.5/lib/dictBuilder -I../subprojects/zstd-1.4.5/lib/deprecated -I../subprojects/zstd-1.4.5/lib/legacy -I../subprojects/reproc/reproc/inclu= de -Isubprojects/reproc/__CMake_build -I../subprojects/reproc/__CMake_build -Isubprojects/reproc -I../subprojects/reproc -Isubprojects/pcre-8.37 -I../subprojects/pcre-8.37 -Isubprojects/pcre2-10.39 -I../subprojects/pcre2-10.39 -I../subprojects/pcre2-10.39/src -Isubprojects/xxHash-0.8.0 -I../subprojects/xxHash-0.8.0 -Isubprojects/json-glib -I../subprojects/json-glib -I../subprojects/zix/inc= lude -Isubprojects/gtk4/gtk/css -Isubprojects/gtk4/gsk -Isubprojects/libbacktrace -Isubprojects/json-glib/json-glib -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -I/home/alex/local/inc= lude -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib/graphene-1.0/include -I/usr/include/lzo -I/usr/include/graphviz -I/usr/include/guile/3.0 -I/usr -I/usr/include/carla -I/usr/include/carla/includes -I/usr/include/serd-0 -I/usr/include/sord-0 -I/usr/include/sratom-0 -I/usr/include/lilv-0 -I/usr/include/gtksourceview-5 -I/home/alex/local/include/gtk-4.0 -I/home/alex/local/include/pango-1.0 -I/usr/include/libxml2 -I/usr/include/valgrind -I/home/alex/Documents/git/zrythm/build/subprojects/libbacktrace/dist/home/= alex/local/include -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -fdiagnostics-color=3Da= lways -D_FILE_OFFSET_BITS=3D64 -Wall -Winvalid-pch -Wextra -std=3Dgnu11 -O0 -g -DGLIB_VERSION_MIN_REQUIRED=3DGLIB_VERSION_2_70 -DGLIB_VERSION_MAX_ALLOWED=3DGLIB_VERSION_2_70 -DGDK_VERSION_MIN_REQUIRED=3DGDK_VERSION_4_8 -DGDK_VERSION_MAX_ALLOWED=3DGDK_VERSION_4_8 -Wno-bad-function-cast -Wno-old-style-declaration -Werror=3Dabsolute-value -Wformat=3D2 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-sequence-point -Wignored-qualifiers -Wno-cast-function-type -Walloca -fno-common -frecord-gcc-switches -march=3Dnative -mtune=3Dnative -ffast-math -fstrengt= h-reduce -fdata-sections -ffunction-sections -freciprocal-math -fsingle-precision-constant -msse -msse2 -mfpmath=3Dsse -fno-math-errno -fno-omit-frame-pointer -g3 -rdynamic -funwind-tables -fasynchronous-unwind-tables -fno-toplevel-reorder '-DGETTEXT_PACKAGE=3D"zr= ythm"' -fPIC -DZIX_STATIC -DXXH_INLINE_HINTS -DXXH_STATIC_LINKING_ONLY -mfpmath=3D= sse -msse -msse2 -pthread -DREAL_BUILD -D_REENTRANT -isystem/usr/include/graphene-1.0 -isystem/usr/lib/graphene-1.0/include -mfpmath=3Dsse -msse -msse2 -isystem/usr/include/glib-2.0 -isystem/usr/lib/glib-2.0/include -isystem/usr/include/sysprof-4 -isystem/home/alex/local/include -mfpmath=3Dsse -msse -msse2 -Wformat=3D2 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-sequence-point -Wignored-qualifiers -Wno-cast-function-type -Walloca -fno-common '-DLV2_UI__Gtk4UI=3D"https://lv2plug.in/ns/extensions/ui#Gtk4UI"' '-D__(x)= =3Dx' -DG_LOG_USE_STRUCTURED=3D1 '-DG_LOG_DOMAIN=3D"zrythm"' -DREALTIME=3D '-DDEPRECATED_MSG(x)=3D__attribute__((deprecated(x)))' '-DOPTIMIZE(x)=3D__attribute__((optimize(#x)))' '-DOPTIMIZE_O0=3DOPTIMIZE(O= 0)' '-DOPTIMIZE_O1=3DOPTIMIZE(O1)' '-DOPTIMIZE_O2=3DOPTIMIZE(O2)' '-DOPTIMIZE_O3=3DOPTIMIZE(O3)' '-DNOINLINE=3D__attribute__((noinline))' '-DNONNULL_ARGS(...)=3D__attribute__((nonnull(__VA_ARGS__)))' '-DACCESS(...)=3D__attribute__((access(__VA_ARGS__)))' '-DACCESS_READ_ONLY(...)=3DACCESS(read_only,__VA_ARGS__)' -frecord-gcc-swit= ches '-DALWAYS_INLINE=3D__attribute__((always_inline))' '-DCOLD=3D__attribute__(= (cold))' '-DHOT=3D__attribute__((hot))' '-DPURE=3D__attribute__((pure))' '-DNONNULL=3D__attribute__((nonnull))' '-DRETURNS_NONNULL=3D__attribute__((returns_nonnull))' '-DSTACK_PROTECT=3D__attribute__((stack_protect))' '-DNO_STACK_PROTECTOR=3D__attribute__((no_stack_protector))' '-DWARN_UNUSED_RESULT=3D__attribute__((warn_unused_result))' '-DCONST=3D__attribute__((const))' '-DMALLOC=3D__attribute__((malloc))' -march=3Dnative -mtune=3Dnative -ffast-math -fstrength-reduce -DPIC -fdata-= sections -ffunction-sections -freciprocal-math -fsingle-precision-constant -msse -ms= se2 -mfpmath=3Dsse -fno-math-errno -fno-omit-frame-pointer -g3 -rdynamic -funwind-tables -fasynchronous-unwind-tables -fno-toplevel-reorder -Werror=3Dformat-overflow -Werror=3Dformat-truncation -Werror=3Dclobbered -Werror=3Ddisabled-optimization -Werror=3Dfloat-equal -Werror=3Dlogical-op -Werror=3Dpointer-arith -Werror=3Denum-conversion -Werror=3Doverlength-stri= ngs -Werror=3Dstringop-truncation -Werror=3Dmissing-declarations -Werror=3Dint-to-pointer-cast -Werror=3Dshadow -Werror=3Dundef -Werror=3Dun= used -fstrict-aliasing -Wstrict-aliasing=3D2 -Werror=3Dstrict-aliasing -Wstrict-overflow=3D2 -fstrict-overflow -Werror=3Dduplicated-branches -Werror=3Dduplicated-cond -Werror=3Dnull-dereference -Werror=3Dinit-self -Werror=3Djump-misses-init -Werror=3Dmissing-prototypes -Werror=3Dnested-ex= terns -Werror=3Dwrite-strings -Werror=3Dsign-compare -Werror=3Ddiscarded-qualifie= rs -Werror=3Dfloat-conversion -Werror=3Dimplicit-function-declaration -Werror=3Duninitialized -Werror=3Dmaybe-uninitialized -Werror=3Dreturn-type -Werror=3Dint-conversion -Werror=3Dincompatible-pointer-types -Werror=3Dimp= licit-int -Werror=3Dmultistatement-macros -Werror=3Dswitch -Werror=3Doverflow -Werror=3Darray-bounds -Werror=3Denum-compare -Werror=3Dmisleading-indentat= ion -Werror=3Dint-in-bool-context -Werror=3Dtype-limits -Werror=3Ddeprecated-de= clarations -Werror=3Dendif-labels -Werror=3Dlogical-not-parentheses -Werror=3Dparenthe= ses -Werror=3Dcomment -Werror=3Dsizeof-pointer-div -Werror=3Dshift-count-overfl= ow -Werror=3Dfree-nonheap-object -fanalyzer -Werror=3Danalyzer-possible-null-dereference -Werror=3Danalyzer-malloc-leak -Werror=3Danalyzer-null-dereference -Werror=3Danalyzer-null-argument -Werror=3Danalyzer-use-after-free -Werror=3Danalyzer-possible-null-argument -Werror=3Danalyzer-double-free -Werror=3Danalyzer-file-leak -Werror=3Danalyzer-use-of-uninitialized-value -Werror=3Danalyzer-out-of-bou= nds -Werror=3Dnonnull -Werror=3Dnonnull-compare -Werror=3Doverride-init -Werror=3Dbool-compare -Werror=3Dtautological-compare -Werror=3Dunused-resu= lt -Werror=3Dinline -Werror=3Dduplicate-decl-specifier -Werror=3Dredundant-dec= ls -Werror=3Dstrict-prototypes -Werror=3Dsizeof-array-argument -Werror=3Dlto-type-mismatch -Werror=3Dodr -Wsuggest-attribute=3Dpure -Wsuggest-attribute=3Dconst -Wsuggest-attribute=3Dnoreturn -Wsuggest-attribute=3Dformat -Wsuggest-attribute=3Dmalloc -Wsuggest-attribu= te=3Dcold -Werror=3Dsign-conversion -Werror=3Dimplicit-fallthrough -Werror=3Dformat= =3D2 -MD -MQ src/libzrythm-lib.so.p/audio_exporter.c.o -MF src/libzrythm-lib.so.p/audio_exporter.c.o.d -o src/libzrythm-lib.so.p/audio_exporter.c.o -c ../src/audio/exporter.c ```=