This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13371] New: c++ code generation bug
- From: "dje at sebabeach dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Dec 2003 07:32:52 -0000
- Subject: [Bug c++/13371] New: c++ code generation bug
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
cc1plus generates bad code for this testcase.
An infinite loop is generated. I think it's because a scope statement is
emitted twice (or something like that). you can see
the bug in the .00.rtl file.
I was able to recreate this with the gcc-ss-3_3-20031208 tag.
Compile with ./cc1plus -quiet -O2 foo.cc
enum state_e
{
STATE_0 = 0,
STATE_1 = 1,
};
struct packed_state_t
{
state_e state : 8;
} __attribute__ ((packed));
class foo_c
{
public:
void set_state (unsigned p, state_e s);
};
class bar_c
{
public:
struct
{
unsigned a;
unsigned b;
} r;
__inline__ unsigned get_a () const { return this->r.a; }
__inline__ unsigned get_b () const { return this->r.b; }
__inline__ unsigned
get_u (unsigned a) const
{
return a + this->get_b ();
}
packed_state_t* state;
foo_c* foo_if;
void set_state (unsigned p, state_e s);
};
enum state_params_e
{
STATE_LOG_CHUNK_SZ = 7,
STATE_CHUNK_SZ = 1 << STATE_LOG_CHUNK_SZ
};
static __inline__ unsigned
get_state_index (unsigned a)
{
return a >> STATE_LOG_CHUNK_SZ;
}
void
bar_c::set_state (unsigned p, state_e s)
{
unsigned u = this->get_u (p);
if (u < this->get_a ())
{
this->state [get_state_index (u)].state = s;
return;
}
this->foo_if->set_state (p, s);
}
Study the resulting assembly for the `if' clause and you'll see this:
.L7:
movl %edx, %eax
shrl $7, %eax
movb %bl, (%eax,%ecx)
jmp .L7
--
Summary: c++ code generation bug
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dje at sebabeach dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13371