Subject: gcc-12: Miscompilation of attached test files, gcc-11 ok Package: gcc-12 X-Debbugs-Cc: c...@debian.org Version: 12.2.0-9 Severity: important
This prevents GCL using gcc-12..... ============================================================================= File: t.c ============================================================================= #include <stdio.h> #define fixnum long #define ufixnum unsigned long fixnum foo(fixnum i,fixnum x) { printf("foo\n"); return x; } fixnum bar(fixnum x) { printf("bar\n"); return x; } struct fixn { fixnum d; fixnum FIXVAL; }; union lu { struct fixn FIX; }; typedef union lu *object; extern object fixnum_add(fixnum,fixnum); extern object make_fixnum1(fixnum); object baz(object x) { { fixnum fx=({register object _q2=(x); register fixnum _q3; _q3=(((ufixnum)(_q2))>=0x8000000000000000) ? ((fixnum)(((fixnum)(_q2))-(0x8000000000000000 +(0x4000000000000000>>1)))) : (_q2)->FIX.FIXVAL; _q3;}); return fx==( - ((long)((((unsigned long)1)<<((8*8)-1))-1)) - 1 ) ? fixnum_add(1,((long)((((unsigned long)1)<<((8*8)-1))-1))) : (fx<0 ? ({register fixnum _q1=(-fx); register object _q4; _q4=(!(((_q1)+(0x4000000000000000>>1))&-0x4000000000000000)) ? ((object)((_q1)+(0x8000000000000000 +(0x4000000000000000>>1)))) : make_fixnum1(_q1); _q4;}) : x); } } int main(int argc,char * argv[]) { fixnum fx; union lu u; sscanf(argv[1],"%ld",&fx); u.FIX.FIXVAL=fx; printf("%p\n",baz(&u)); return 0; } ============================================================================= File: tt.c ============================================================================= #include <stdio.h> #define fixnum long struct fixn { fixnum d; fixnum FIXVAL; }; union lu { struct fixn FIX; }; typedef union lu *object; object fixnum_add(fixnum x,fixnum y) { static union lu u; u.FIX.FIXVAL=1; printf("add\n"); return &u; } object make_fixnum1(fixnum x) { static union lu u; u.FIX.FIXVAL=x; printf("make\n"); return &u; } ============================================================================= Transcript: ============================================================================= (sid_amd64-dchroot)camm@barriere:~$ gcc-12 -c -g -ffile-prefix-map=/home/camm/gcl-2.6.12=. -fstack-protector-strong -Wformat -Werror=format-security -fsigned-char -pipe -fcommon -fno-builtin-malloc -fno-builtin-free -fno-PIE -fno-pie -fno-PIC -fno-pic -Wall -Wno-empty-body -Wno-unused-but-set-variable -I/usr/include/tirpc -pg -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -I/home/camm/gcl-2.6.12/o -I../h -I../gcl-tk tt.c (sid_amd64-dchroot)camm@barriere:~$ gcc-12 -c -g -ffile-prefix-map=/home/camm/gcl-2.6.12=. -fstack-protector-strong -Wformat -Werror=format-security -fsigned-char -pipe -fcommon -fno-builtin-malloc -fno-builtin-free -fno-PIE -fno-pie -fno-PIC -fno-pic -Wall -Wno-empty-body -Wno-unused-but-set-variable -I/usr/include/tirpc -pg -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -I/home/camm/gcl-2.6.12/o -I../h -I../gcl-tk t.c (sid_amd64-dchroot)camm@barriere:~$ gcc-12 -Wl,-no-pie t.o tt.o -o t (sid_amd64-dchroot)camm@barriere:~$ ./t -8874444426961747968 0x1b285c3000000000 (sid_amd64-dchroot)camm@barriere:~$ gcc-11 -c -g -ffile-prefix-map=/home/camm/gcl-2.6.12=. -fstack-protector-strong -Wformat -Werror=format-security -fsigned-char -pipe -fcommon -fno-builtin-malloc -fno-builtin-free -fno-PIE -fno-pie -fno-PIC -fno-pic -Wall -Wno-empty-body -Wno-unused-but-set-variable -I/usr/include/tirpc -pg -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -I/home/camm/gcl-2.6.12/o -I../h -I../gcl-tk t.c (sid_amd64-dchroot)camm@barriere:~$ gcc-12 -Wl,-no-pie t.o tt.o -o t (sid_amd64-dchroot)camm@barriere:~$ ./t -8874444426961747968 make 0x404050 (sid_amd64-dchroot)camm@barriere:~$ gcc-12 -c -g -ffile-prefix-map=/home/camm/gcl-2.6.12=. -fstack-protector-strong -Wformat -Werror=format-security -fsigned-char -pipe -fcommon -fno-builtin-malloc -fno-builtin-free -fno-PIE -fno-pie -fno-PIC -fno-pic -Wall -Wno-empty-body -Wno-unused-but-set-variable -I/usr/include/tirpc -pg -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -I/home/camm/gcl-2.6.12/o -I../h -I../gcl-tk t.c (sid_amd64-dchroot)camm@barriere:~$ gcc-12 -Wl,-no-pie t.o tt.o -o t (sid_amd64-dchroot)camm@barriere:~$ ./t -8874444426961747968 0x1b285c3000000000 ============================================================================= -- System Information: Debian Release: bookworm/sid APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'unstable') merged-usr: no Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-19-amd64 (SMP w/4 CPU threads) Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: unable to detect Versions of packages gcc-12 depends on: ii binutils 2.39-8 ii cpp-12 12.2.0-9 ii gcc-12-base 12.2.0-9 ii libc6 2.36-4 ii libcc1-0 12.2.0-9 ii libgcc-12-dev 12.2.0-9 ii libgcc-s1 12.2.0-9 ii libgmp10 2:6.2.1+dfsg1-1.1 ii libisl23 0.25-1 ii libmpc3 1.2.1-2 ii libmpfr6 4.1.0-3 ii libstdc++6 12.2.0-9 ii libzstd1 1.5.2+dfsg-1 ii zlib1g 1:1.2.13.dfsg-1 Versions of packages gcc-12 recommends: ii libc6-dev 2.36-4 Versions of packages gcc-12 suggests: pn gcc-12-doc <none> pn gcc-12-locales <none> pn gcc-12-multilib <none> -- no debconf information -- Camm Maguire c...@maguirefamily.org ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah