From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 858313857018; Thu, 21 Apr 2022 08:46:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 858313857018 From: "kamilcukrowski at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/105331] New: -Wmaybe-uninitialized warning on va_arg with double _Complex on va_list pointer Date: Thu, 21 Apr 2022 08:46:07 +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: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kamilcukrowski at gmail dot com 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 08:46:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105331 Bug ID: 105331 Summary: -Wmaybe-uninitialized warning on va_arg with double _Complex on va_list pointer Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: kamilcukrowski at gmail dot com Target Milestone: --- Passing a pointer to `va_list` to a function, and then using `va_arg` with = type `double _Complex` with derefenced pointer to `va_list` results in a false positive `-Wmaybe-uninitailized` warning. It is a false-positive - it's a pointer to `va_list`, the pointed-to value is just initialized by the calle= r. Note that this triggers _only_ with `double _Complex` type. Neither `long double _Complex` or `float _Complex` or `double` or any other type. > the exact version of GCC; the options given when GCC was configured/built; $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --enable-languages=3Dc,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-boots= trap --prefix=3D/usr --libdir=3D/usr/lib --libexecdir=3D/usr/lib --mandir=3D/usr= /share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttps://bugs.archlinux.org/ --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdcxx-pch --disable-werror --with-build-config=3Dbootstrap-lto --enable-link-serialization=3D1 gdc_include_dir=3D/usr/include/dlang/gdc Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (GCC)=20 > the system type; $ uname -a Linux leonidas 5.17.1-zen1-1-zen #1 ZEN SMP PREEMPT Mon, 28 Mar 2022 21:56:= 46 +0000 x86_64 GNU/Linux $ cat /etc/arch-release=20 Arch Linux release > the complete command line that triggers the bug; the compiler output (err= or messages, warnings, etc.);=20 $ gcc --save-temps -O -Wmaybe-uninitialized -c example.c example.c: In function =E2=80=98take_double_complex_to_int=E2=80=99: example.c:4:38: warning: =E2=80=98va_arg_tmp.5=E2=80=99 may be used uniniti= alized [-Wmaybe-uninitialized] 4 | return va_arg(*va, double _Complex); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~=20=20=20=20=20=20=20= =20=20 > and the preprocessed file (*.i*) that triggers the bug ``` $ cat example.i=20 # 0 "example.c" # 0 "" # 0 "" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "" 2 # 1 "example.c" typedef __builtin_va_list va_list; int take_double_complex_to_int(va_list *va) { return __builtin_va_arg(*va, double _Complex); } ``` --- Really, it's just: $ cat example.c=20 typedef __builtin_va_list va_list; #define va_arg(ap, type) __builtin_va_arg(ap, type) int take_double_complex_to_int(va_list *va) { return va_arg(*va, double _Complex); } --- I tested docker containers: image gcc:10 works, but image gcc:11.1.0 sh= ows the error : $ dockertest() { if docker run -i --rm $1 gcc -O -Wmaybe-uninitialized -Wer= ror -c -xc - < example.c; then echo "$1: FINE"; else echo "$1: error"; fi; } $ dockertest gcc:10 gcc:10 FINE $ dockertest gcc:11 : In function 'take_double_complex_to_int': :4:21: error: 'va_arg_tmp.5' may be used uninitialized [-Werror=3Dmaybe-uninitialized] cc1: all warnings being treated as errors gcc:11: error=