[Bug c/80341] New: gcc miscompiles division of signed char
vsevolod.livinskij at frtk dot ru
gcc-bugzilla@gcc.gnu.org
Thu Apr 6 10:48:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80341
Bug ID: 80341
Summary: gcc miscompiles division of signed char
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: vsevolod.livinskij at frtk dot ru
Target Milestone: ---
Created attachment 41140
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41140&action=edit
Reproducer.
GCC generates incorrect code. Correct result is 90.
Reproducer:
>$ cat foo.c
extern const signed char var_25;
extern signed char var_465;
void foo() {
var_465 = (unsigned short) var_25 / -55;
}
>$ cat main.c
#include <stdio.h>
extern void foo ();
const signed char var_25 = -84;
signed char var_465 = 0;
int main () {
foo ();
printf("%d\n", (int) var_465);
return 0;
}
Run:
>$ gcc main.c foo.c ; ./a.out
1
GCC version:
Rev. 246681
>$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/vsevolod/workspace/gcc-dev/bin-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/vsevolod/workspace/gcc-dev/trunk/configure
--prefix=/home/vsevolod/workspace/gcc-dev/bin-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.1 20170404 (experimental) (GCC)
More information about the Gcc-bugs
mailing list