AMENDED PATCH Re: Fix for infinite loop on x86_64 (PR 18300)

Zak Kipling zak@transversal.com
Fri Nov 12 12:44:00 GMT 2004


[ Amended and re-tested version of my previous patch, following comments 
from Roger Sayle, below. ]

DESCRIPTION

This patch (against current CVS HEAD) fixes the infinite loop bug 
described in PR 18300 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18300).

Briefly, this causes the compiler to go into an infinite loop when an 
object with > 3 base classes is passes as an argument by value in C++ on 
the x86_64 architecture. It is caused by the re-use of a loop index 
variable without a shadowing declaration in the classify_argument 
function in gcc/config/i386/i386.c -- my patch removes the shadowing by 
introducing a new loop variable, leaving a single declaration of "i", 
which is now only used by one loop at a time.

It's a tiny patch, so I'm assuming copyright assignment papers won't be 
needed.


CHANGELOG

2004-11-10  Zak Kipling  <zak@transversal.com>

	PR target/18300
	* config/i386/i386.c (classify_argument): Fix infinite loop when
	passing object with 3 or more base classes by value.

testsuite/

	PR target/18300
	* g++.dg/other/infloop-1.C: New test case.


TESTING

The patch includes a new testcase, as shown in the ChangeLog entry.

I have tested the patch on both i686-pc-linux-gnu and 
x86_64-pc-linux-gnu, and have observed no new testsuite failures, save 
some seemingly-nondeterministic changes in the number of iterations of 
the libmudflap.cth tests which failed.

On both architectures, the new test passes when the i386.c patch is 
applied; on x86_64 it fails without the patch, correctly detecting PR 
target/18300.


PATCH follows as attachment


Roger Sayle wrote:
> On Wed, 10 Nov 2004, Zak Kipling wrote:
> 
>>CHANGELOG
>>
>>Fixes PR target/18300: Infinite loop when passing object with 3+ base
>>classes by value.
> 
> 
> The ChangeLog entry should really be written as:
> 
> 2004-11-10  Zak Kipling  <zak@transversal.com>
> 
> 	PR target/18300
> 	* config/i386/i386.c (classify_argument): Fix infinite loop when
> 	passing object with 3 or more base classes by value.
> 
> testsuite/
> 
> 	PR target/18300
> 	* g++.dg/other/infloop-1.C: New test case.
> 
> 
> 
> My personal preference would be instead of shadowing the variable i
> and having two nested loops with the same index variable, to rename
> the conflicting inner loops to use a different variable, such as "j".
> 
> Could you retest and resubmit your patch with that change and the
> above ChangeLog entry?
> 
> Thanks in advance,
> 
> Roger
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gcc-infloop-patch.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041112/7472515f/attachment.ksh>


More information about the Gcc-patches mailing list