https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94641

            Bug ID: 94641
           Summary: -Wpadded -fsanitize=undefined together cause warning
                    on main()
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: edgardragon444 at gmail dot com
  Target Milestone: ---

Hi, as I'm fiddling with warning flags (yep, synthesizing -Weverything, what
could go wrong?)

The '-fsanitize=undefined' causes the '-Wpadded' to misbehave, telling me
 'main()' struct size is being padded. Disabling UBsan silences the warning.

Happens when all three are true:
1. -fsanitize=undefined flag specified
2. -Wpadded flag specified
3. printf() used

Maybe dup of bug 68901, yet that's c++ with function nested within a struct.
I'm C, and only have printf(). 

Seen on 8.3.0, 9.2.0 and trunk (https://godbolt.org/z/jFSPf_).
> ed@Fold ~ $ (gcc -xc /dev/fd/9 -Wpadded -fsanitize=address -o 
> /dev/null)9<<<$'#include <stdio.h>\nint main() {printf("Hi"); return 0;}'
> ed@Fold ~ $ (gcc -xc /dev/fd/9 -Wpadded -fsanitize=undefined -o 
> /dev/null)9<<<$'#include <stdio.h>\nint main() {printf("Hi"); return 0;}'
> /dev/fd/9: In function ‘main’:
> /dev/fd/9:2:1: warning: padding struct size to alignment boundary [-Wpadded]
>     2 | int main() {printf("Hi"); return 0;}
>       | ^~~
> ed@Fold ~ $ (gcc -xc /dev/fd/9 -Wpadded -fsanitize=undefined -o 
> /dev/null)9<<<$'#include <stdio.h>\nint main() {return 0;}'
> ed@Fold ~ $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
> Target: x86_64-pc-linux-gnu
> Configured with: 
> /tmp/portage/portage/sys-devel/gcc-9.2.0-r4/work/gcc-9.2.0/configure 
> --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr 
> --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/9.2.0 
> --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include 
> --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0 
> --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/man 
> --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/info 
> --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9 
> --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/python 
> --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt 
> --disable-werror --with-system-zlib --enable-nls --without-included-gettext 
> --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ 
> --with-pkgversion='Gentoo 9.2.0-r4 p5' --disable-esp --enable-libstdcxx-time 
> --with-build-config=bootstrap-lto --enable-shared --enable-threads=posix 
> --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib 
> --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point 
> --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp 
> --disable-systemtap --enable-vtable-verify --enable-lto --with-isl 
> --disable-isl-version-check --enable-default-pie --enable-default-ssp
> Thread model: posix
> gcc version 9.2.0 (Gentoo 9.2.0-r4 p5)
> ed@Fold ~ $

Reply via email to