http://bugzilla.suse.com/show_bug.cgi?id=1169156 Bug ID: 1169156 Summary: GCC9 wrong handling of builtin_constant_p() Classification: openSUSE Product: openSUSE Distribution Version: Leap 15.2 Hardware: Other OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: Development Assignee: matz@suse.com Reporter: ptesarik@suse.com QA Contact: qa-bugs@suse.de CC: msuchanek@suse.com, nborisov@suse.com, tiwai@suse.com Found By: --- Blocker: --- Created attachment 835407 --> http://bugzilla.suse.com/attachment.cgi?id=835407&action=edit Reproducer GCC9 does not handle builtin_constant_p() correctly in some cases. The offending statement is this: buf->f_bavail = div_u64(total_free_data, factor); However, factor is not a build-time constant. It is initialized to 1, but it may be later set to the result of an extern function call (i.e. GCC cannot make any assumptions about its return value). IIUC GCC does not know with any certainty whether the value is constant, or not, so it generates code for both cases. The code is originally taken from the Linux kernel sources, fails because of unresolved references to __aeabi_uldivmod. I have trimmed it down and made it self-contained. It is not (yet) a minimal reproducer, but getting close. Build it with a 32-bit ARM compiler (native or cross-compiler) like this: $ gcc-9 -nostdinc -std=gnu89 -marm -march=armv7-a -O2 -c gcc9-arm-div.c -o gcc9-arm-div.o I used native gcc-9 from openSUSE:Leap:15.2:ARM to verify the bug: $ gcc-9 -v Using built-in specs. COLLECT_GCC=gcc-9 COLLECT_LTO_WRAPPER=/usr/lib/gcc/armv7hl-suse-linux-gnueabi/9/lto-wrapper Target: armv7hl-suse-linux-gnueabi Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,fortran,go --disable-werror --with-gxx-include-dir=/usr/include/c++/9 --enable-ssp --disable-libssp --disable-libvtv --disable-cet --disable-libcc1 --disable-plugin --with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib --with-system-zlib --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-9 --without-system-libunwind --with-arch=armv7-a --with-tune=cortex-a15 --with-float=hard --with-abi=aapcs-linux --with-fpu=vfpv3-d16 --disable-sjlj-exceptions --build=armv7hl-suse-linux-gnueabi --host=armv7hl-suse-linux-gnueabi Thread model: posix gcc version 9.2.1 20190820 [gcc-9-branch revision 274748] (SUSE Linux) It can also be reproduced with a cross-compiler. -- You are receiving this mail because: You are on the CC list for the bug.