This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/12362] New: Compiler generates incorrect code at -O2
- From: "sean at mcneil dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Sep 2003 05:29:44 -0000
- Subject: [Bug c/12362] New: Compiler generates incorrect code at -O2
- 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=12362
Summary: Compiler generates incorrect code at -O2
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sean at mcneil dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-unknown-freebsd4.9
GCC target triplet: mips-wrs-vxworks
The following code compiled with
mips-wrs-vxworks-gcc -c -O2 early.c
produces erroneous code. It is essentially returning within the if statement
instead of falling through to complete the function.
early.c:
#define EARLY 4
typedef struct
{
int status;
int node;
} ID;
typedef int (*FUNCPTR) ();
typedef struct
{
FUNCPTR removeRtn;
FUNCPTR calibrateRtn;
FUNCPTR putRtn;
} Q_CLASS;
typedef struct
{
Q_CLASS *pQClass;
} Q_HEAD;
typedef int Q_NODE;
extern int ticks;
extern ID *id;
extern Q_HEAD queue;
extern Q_HEAD t_queue;
#define Q_REMOVE(pQHead,pQNode) \
(*(((Q_HEAD *)(pQHead))->pQClass->removeRtn)) \
(((Q_HEAD *)(pQHead)), ((Q_NODE *)(pQNode)))
#define Q_CALIBRATE(pQHead,keyDelta) \
(*(((Q_HEAD *)(pQHead))->pQClass->calibrateRtn)) \
(((Q_HEAD *)(pQHead)), ((int)(keyDelta)))
#define Q_PUT(pQHead,pQNode,key) \
(*(((Q_HEAD *)(pQHead))->pQClass->putRtn)) \
(((Q_HEAD *)(pQHead)), ((Q_NODE *)(pQNode)), (key))
int early (register int timeout)
{
Q_REMOVE (&queue, id);
if ((unsigned)(ticks + timeout) < ticks)
{
Q_CALIBRATE (&t_queue, ~ticks + 1);
ticks = 0;
}
Q_PUT (&queue, &id->node, timeout + ticks);
id->status |= EARLY;
return 0;
}