Debian Bug report logs - #1023756
gcc-12: Miscompilation of attached test files, gcc-11 ok

version graph

Package: gcc-12; Maintainer for gcc-12 is Debian GCC Maintainers <[email protected]>; Source for gcc-12 is src:gcc-12 (PTS, buildd, popcon).

Reported by: Camm Maguire <[email protected]>

Date: Wed, 9 Nov 2022 17:15:02 UTC

Severity: important

Found in version gcc-12/12.2.0-9

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], [email protected], Debian GCC Maintainers <[email protected]>:
Bug#1023756; Package gcc-12. (Wed, 09 Nov 2022 17:15:04 GMT) (full text, mbox, link).


Acknowledgement sent to Camm Maguire <[email protected]>:
New Bug report received and forwarded. Copy sent to [email protected], Debian GCC Maintainers <[email protected]>. (Wed, 09 Nov 2022 17:15:04 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Camm Maguire <[email protected]>
To: [email protected],[email protected],[email protected],[email protected],[email protected]
Subject: gcc-12: Miscompilation of attached test files, gcc-11 ok
Date: Wed, 09 Nov 2022 12:02:18 -0500
Subject: gcc-12: Miscompilation of attached test files, gcc-11 ok
Package: gcc-12
X-Debbugs-Cc: [email protected]
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			     		    [email protected]
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



Information forwarded to [email protected], Debian GCC Maintainers <[email protected]>:
Bug#1023756; Package gcc-12. (Sun, 08 Jan 2023 08:21:02 GMT) (full text, mbox, link).


Acknowledgement sent to Matthias Klose <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <[email protected]>. (Sun, 08 Jan 2023 08:21:02 GMT) (full text, mbox, link).


Message #10 received at [email protected] (full text, mbox, reply):

From: Matthias Klose <[email protected]>
To: [email protected], Camm Maguire <[email protected]>
Subject: Re: gcc-12: Miscompilation of attached test files, gcc-11 ok
Date: Sun, 8 Jan 2023 09:16:51 +0100
Please could you prepare a self-contained test case, either adding the required 
included files, or providing the preprocessed source?

Also, please with the recent GCC 11, 12 versions in unstable, and the GCC 13 
snapshot in experimental.



Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 13:13:18 2025; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.