This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13740] ICE when mangling template which uses typeof
- From: "ian at wasabisystems dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jan 2004 16:42:21 -0000
- Subject: [Bug c++/13740] ICE when mangling template which uses typeof
- References: <20040119145352.13740.ian@airs.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From ian at wasabisystems dot com 2004-01-19 16:42 -------
Subject: Re: ICE when mangling template which uses typeof
"gdr at integrable-solutions dot net" <gcc-bugzilla@gcc.gnu.org> writes:
> ------- Additional Comments From gdr at integrable-solutions dot net 2004-01-19 16:17 -------
> Subject: Re: New: ICE when mangling template which uses typeof
>
> "ian at airs dot com" <gcc-bugzilla@gcc.gnu.org> writes:
>
> | I get an ICE when compiling this test case with the current mainline:
> |
> | template<int n> class X {template<class Y> typeof(Y::y) foo(typeof(Y::y));};
> | class Y { public: static int y; };
> | typeof(Y::y) X<0>::foo<Y>(typeof(Y::y)) { }
> |
> | foo4.cc:3: internal compiler error: in write_type, at cp/mangle.c:1558
> | Please submit a full bug report,
> | with preprocessed source if appropriate.
> | See <URL:http://gcc.gnu.org/bugs.html> for instructions.
>
> I think this is a know bug. Nathan and I had exchanged mails on this
> topic when I first implemented the C++ decltype proposal on the
> cxx-reflection-branch.
>
> http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02242.html
>
> and I believe I have implemented that on the cxx-reflection branch.
>
> Maybe you might want to review his suggestion in the message
> referenced above.
Thanks for the pointer.
I don't think Nathan's proposal will work as-is, because 'X' is
already meaningful in <template-arg> to introduce an <expression> used
as a template argument. Since a <template-arg> can also be a <type>,
we don't want to use 'X' in <type>, since that will make
<template-arg> ambiguous.
For the particular case of the GNU extension typeof, it seems to me
that we can only see that extension in a template argument. Any use
of typeof which appears somewhere else will be reduced to the base
type for the purposes of mangling. I think typeof can be handled as a
unary operator in an expression, must like sizeof(type), which is why
I suggested mangling it as ty <type>.
However, I gather that cxx-reflection requires the ability to mangle
types in a more general manner. In particular, you need to mangle
types which use expressions in some fashion. I don't really know what
cxx-reflection is for, so this is a guess.
Nathan's proposal is quite general but not wholly general. In
particular Nathan's proposal has a nearly arbitrary number of types
and expressions, but they are not put together in an arbitrary way.
Your patch here:
http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02226.html
suggests that you need to be able to specify a single type or a single
expression.
To specify a single type, you can just use the existing U mangling:
<type> ::= U <source-name> <type>
To specify a single expression as part of a <type>, we do need an
extension. We can't use 'X' for this, but we could use 'Y':
<type> ::= Y <expression> E
Or we could follow Nathan's suggestion, using 'Y':
<type> ::= Y <digit1> <digit2> <sourcename> <type>... [n1] <expression>...[n2]
There is no current mangling which works like this, though, so I think
it would be more in the spirit of the current ABI to do this:
<type> ::= Y <sourcename> <template-arg>+ E
This would be described as a vendor-specified type which takes
arbitrary arguments. The arguments are anything which is permitted in
a template expansion, which permits both types and expressions. I
think that ought to be sufficiently flexible.
Ian
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13740