[Bug target/18300] New: Infinite loop when passing object with 3+ base classes by value

zak at transversal dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 4 18:34:00 GMT 2004


On x86_64 (but not on i686) the following legal code sends gcc 3.2.3, 3.3.4 and
current 3.3-branch CVS into an infinite loop.

/////////////////////////////////////////

struct Base1 { };
struct Base2 { };
struct Base3 { };

struct Derived : Base1, Base2, Base3 { };

void foo(Derived);

int main()
{
  foo(Derived());
}

//////////////////////////////////////////


The problem appears to be in classify_argument in gcc/config/i386.c: in both the
 RECORD_TYPE and UNION_TYPE branches, the same loop variable (i) is used in two
nested loops. I'm not sure I fully understand this code, but it seems unlikely
that this is the intention. I'm also not sure if it's possible for this to
result in other failure modes besides the infinite loop, although it certainly
seems possible.

Using two distinct loop variables appears to fix the problem -- a patch will
follow after I've done testsuite runs on current CVS. (Looking at the source,
the above problem appears to still be present on the 3.4 branch and CVS HEAD,
although I've not tested there yet.)

-- 
           Summary: Infinite loop when passing object with 3+ base classes
                    by value
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zak at transversal dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18300



More information about the Gcc-bugs mailing list