This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/1687: Extreme compile time regression from 2.95.2
- To: John David Anglin <dave at hiauly1 dot hia dot nrc dot ca>
- Subject: Re: c++/1687: Extreme compile time regression from 2.95.2
- From: "Zack Weinberg" <zackw at Stanford dot EDU>
- Date: Wed, 14 Feb 2001 19:57:08 -0800
- Cc: gcc-bugs at gcc dot gnu dot org, kelley dot cook at home dot com
- References: <200102150006.TAA15633@hiauly1.hia.nrc.ca>
On Wed, Feb 14, 2001 at 07:06:33PM -0500, John David Anglin wrote:
> While you are looking at this, possibly somebody who understands
> walk_tree/walk_tree_without_duplicates might might see if they can
> resolve a related problem on the vax. I first reported it here:
>
> <http://gcc.gnu.org/ml/gcc-bugs/2000-12/msg00077.html>.
I can *guess*, but I do not claim to understand the tree inliner.
(which is why I'm still waiting for opinions on the patch, hint hint)
My guess is that the PCC return convention for structs, which has the
function return a pointer to a buffer in static memory, has confused
the inliner and created a circular tree. It probably just doesn't
handle that case, because the people who wrote it thought
PCC_STATIC_STRUCT_RETURN was dead.
If this hypothesis is true, then the following program will stick the
vax C++ compiler in an infinite loop, but not the C compiler:
#include <stdio.h>
struct blah { int a[6]; };
inline struct blah foo()
{
struct blah r = { { 12, 24, 36, 48, 60, 72 } };
return r;
}
int
main()
{
struct blah x = foo();
printf("%d %d %d %d %d %d\n", x.a[1], x.a[2], x.a[3],
x.a[4], x.a[5], x.a[6]);
return 0;
}
I feel obliged to point out that the PCC structure return convention
silently corrupts data should you write a recursive function that
returns a structure. That includes a recursive function that returns
a complex number, since they are handled as structures internally.
Hm, we aren't doing as well at optimizing this as we could. We get
bloody weird code from g++ (3.0 branch as of this morning) on x86. I
think it's copying the 'struct blah' initializer from static memory to
one place on the stack, then to another place, and finally pushing
printf's args from there. It oughta just push printf's args straight
from static memory. Oh, and why is the initializer in data, not
rodata?
--
zw "You can tell [the lunatic] by the liberties he takes with
common sense, his flashes of inspiration, and by the fact that
sooner or later he brings up the Templars."
-- Umberto Eco, _Foucault's Pendulum_