[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#945991: marked as done (gcc-8 makes wrong integer comparison when using optimization flag)



Your message dated Sat, 13 Feb 2021 13:07:12 +0000
with message-id <[🔎] E1lAudk-0000FN-1x@fasolo.debian.org>
and subject line Bug#954831: Removed package(s) from unstable
has caused the Debian Bug report #945991,
regarding gcc-8 makes wrong integer comparison when using optimization flag
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
945991: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=945991
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---

Package: gcc-8
Version: 8.3.0-6
Severity: important
File: /usr/bin/gcc

Dear Maintainer,

I have encountered a bug on the simple code below:


#include <stdio.h>

int fits(int x, int n)
{
int TMinn = -(1 << (n-1));
int TMaxn = (1 << (n-1)) - 1;
return x >= TMinn && x <= TMaxn;
}

int main(void)
{
int cnt;
int x = 1<<31;

for(cnt = 1; cnt<=32; cnt++)
{
if (fits(x,cnt))
{
printf(“%d : ok\n”, cnt);
}
else
{
printf(“%d : ko\n”, cnt);
}
}
return 0;
}

When compiled without optimization, the code produces a correct output (comparison is always false except for n=32):


sfaucou@sfaucou-laptop:~/Temp$ gcc bug.c
sfaucou@sfaucou-laptop:~/Temp$ ./a.out
1 : ko
2 : ko
3 : ko
4 : ko
5 : ko
6 : ko
7 : ko
8 : ko
9 : ko
10 : ko
11 : ko
12 : ko
13 : ko
14 : ko
15 : ko
16 : ko
17 : ko
18 : ko
19 : ko
20 : ko
21 : ko
22 : ko
23 : ko
24 : ko
25 : ko
26 : ko
27 : ko
28 : ko
29 : ko
30 : ko
31 : ko
32 : ok

When compiling with optimization, it produces a wrong output (comparison is evaluated to false for n=32):


sfaucou@sfaucou-laptop:~/Temp$ gcc -O bug.c
sfaucou@sfaucou-laptop:~/Temp$ ./a.out
1 : ko
2 : ko
3 : ko
4 : ko
5 : ko
6 : ko
7 : ko
8 : ko
9 : ko
10 : ko
11 : ko
12 : ko
13 : ko
14 : ko
15 : ko
16 : ko
17 : ko
18 : ko
19 : ko
20 : ko
21 : ko
22 : ko
23 : ko
24 : ko
25 : ko
26 : ko
27 : ko
28 : ko
29 : ko
30 : ko
31 : ko
32 : ko

>From what I have seen from the generated code, the optimized version computes the result at compile-time and simply prints the message “ko”.

I have tested the code with various optimization options (-O, -O1, -O2, -O3), for ia32 and x86-64 ISA. I did also reproduce the bug on machine running Ubuntu (same version of gcc).

Syste information as produced by reportbug are given below.

Let me know if you need further information or if I can help in some other way.

Best regards,

Sébastien.

– System Information:
Debian Release: 10.2
APT prefers stable-updates
APT policy: (500, ’stable-updates’), (500, ’stable’)
Architecture: amd64 (x8664)
Foreign Architectures: i386

Kernel: Linux 4.19.0-6-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINTOOTMODULE, TAINTUNSIGNEDMODULE
Locale: LANG=frFR.UTF-8, LCCTYPE=frFR.UTF-8 (charmap=UTF-8), LANGUAGE= (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages gcc-8 depends on:
ii binutils 2.31.1-16
ii cpp-8 8.3.0-6
ii gcc-8-base 8.3.0-6
ii libc6 2.28-10
ii libcc1-0 8.3.0-6
ii libgcc-8-dev 8.3.0-6
ii libgcc1 1:8.3.0-6
ii libgmp10 2:6.1.2+dfsg-4
ii libisl19 0.20-2
ii libmpc3 1.1.0-1
ii libmpfr6 4.0.2-1
ii libstdc++6 8.3.0-6
ii zlib1g 1:1.2.11.dfsg-1

Versions of packages gcc-8 recommends:
ii libc6-dev 2.28-10

Versions of packages gcc-8 suggests:
pn gcc-8-doc <none>
pn gcc-8-locales <none>
ii gcc-8-multilib 8.3.0-6
pn libasan5-dbg <none>
pn libatomic1-dbg <none>
pn libgcc1-dbg <none>
pn libgomp1-dbg <none>
pn libitm1-dbg <none>
pn liblsan0-dbg <none>
pn libmpx2-dbg <none>
pn libquadmath0-dbg <none>
pn libtsan0-dbg <none>
pn libubsan1-dbg <none>

– no debconf information


--- End Message ---
--- Begin Message ---
Version: 1:8.4.0-7+rm

Dear submitter,

as the package gcc-8 has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/954831

The version of this package that was in Debian prior to this removal
can still be found using http://snapshot.debian.org/.

Please note that the changes have been done on the master archive and
will not propagate to any mirrors until the next dinstall run at the
earliest.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmaster@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Joerg Jaspert (the ftpmaster behind the curtain)

--- End Message ---

Reply to: