This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/11399] New: gcc 3.3.1 miscompiles an if - else if - else statement with O1 on ia64
- From: "ianw at gelato dot unsw dot edu dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Jul 2003 00:06:28 -0000
- Subject: [Bug c/11399] New: gcc 3.3.1 miscompiles an if - else if - else statement with O1 on ia64
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11399
Summary: gcc 3.3.1 miscompiles an if - else if - else statement
with O1 on ia64
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ianw at gelato dot unsw dot edu dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: ia64-unknown-linux-gnu
GCC host triplet: ia64-unknown-linux-gnu
GCC target triplet: ia64-unknown-linux-gnu
gcc 3.3.1 miscompiles the following program at optimisation >= 1 on ia64. The
program will segfault. I noticed this when I was building Apache.
--- start test.c ---
#include <stdio.h>
#include <string.h>
int retval;
const char *if_else(void)
{
if (!strcasecmp("this is", "false")) {
retval = 0;
} else if (!strcasecmp("true", "true")) {
retval = 1;
} else
return "a string";
return "ok";
}
int main(void)
{
printf("%s\n", if_else());
}
--- end test.c ---
The offending code from gcc -S
br.call.sptk.many b0 = strcasecmp#
;;
.mii
mov r1 = r34
cmp4.ne p6, p7 = 0, r8
;;
addl r14 = @ltoffx(retval#), r1
;;
.mii
ld8.mov r15 = [r14], retval#
addl r14 = @ltoffx("a string"), r1
;;
(p7) addl r14 = 1, r0 <---- set r14 to 1
;;
.mmb
(p6) ld8.mov r8 = [r14], "a string" <---- segfault
(p7) st4 [r15] = r14
(p7) br.cond.dptk .L3
This does compile OK with gcc 3.2 and gcc 3.4