This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: debug/6436: dwarf2out ICE with typedef using attributes
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: Jason Merrill <jason at redhat dot com>
- Cc: jakub at gcc dot gnu dot org, <gcc-bugs at gcc dot gnu dot org>, <meissner at suse dot de>,<gcc-gnats at gcc dot gnu dot org>, <gcc-patches at gcc dot gnu dot org>,Mark Mitchell <mark at codesourcery dot com>,Richard Sandiford <rsandifo at redhat dot com>
- Date: Mon, 29 Apr 2002 14:32:14 -0400 (EDT)
- Subject: Re: debug/6436: dwarf2out ICE with typedef using attributes
On Mon, 29 Apr 2002, Jason Merrill wrote:
> This fix seems reasonable; I'll apply it after testing. I'm a bit
> uncomfortable with the typedef pointing to its own type, though; what do
> other people think the effect of Jakub's testcase should be?
>
> Richard Sandiford's recent patch tries to deal with this sort of situation
> by separating the typedef type and underlying struct type; why isn't that
> working here?
>
Here's a kicker, probably related: The exact code in question works
perfectly in C. IE run jakub's test under cc1, and it does fine.
In fact, I was about to email Jakub saying i couldn't reproduce, wwhne i
noticed the original testcase was in C++. So i tried cc1plus, and boom.
Analyzing what goes right in C:
We start the same path, getting the member_declared_type of a, seeing it's
A, and going to output a type die for A *with* alignment.
It gets the main variant, which, just like C++, is A *without* alignment.
...
Okay, well, by that point, the A *without* alignment is already written
out, so it returns right there.
Which is the difference and why C works.
SO let me back up.
The first type we output for C is an unnamed type that is A *without*
alignment.
I.E. TYPE_NAME (type) == NULL
It's output from finish_struct, which calls rest_of_type_compilation,
which calls dwarf2out_decl (TYPE_STUB_DECL (type)).
Then we output unsigned int, then another unnamed type that is A with
alignment.
Then we get to output A, whose main variant is the *unnamed* type we wrote
out before. Thus, TYPE_NAME (type) == NULL, and we go about our merry
way.
So it works fine.
For C++, we output two *named* types first, ._0, which is the A *without*
alignment, then ._1, which is the A *with* alignment.
I.E. TYPE_NAME (type) != NULL on either of them.
Eventually we go to output A, whose main variant is not either of the
named type, but another type named "A" without the alignment.
This is what starts the dominoes falling.
If the main variant of A was ._0, we should be fine.
Or, if we output the second "A" type that seemed to materialize out of
nowhere, before trying to output the real "A", we'd be fine.
My gut feeling is the main variant of A with alignment should be ._0, not
this other type named "A" without alignment that seemed to materialize out
of nowhere, and was never output.
But this is just because it "feels" right, and what C does.
I may be completely wrong.
> 2002-04-29 Jason Merrill <jason@redhat.com>
>
> * dwarf2out.c (gen_type_die): Don't recurse on a self-referential
> typedef.
>
>