[Bug c++/13740] ICE when mangling template which uses typeof

gdr at integrable-solutions dot net gcc-bugzilla@gcc.gnu.org
Mon Jan 19 17:43:00 GMT 2004


------- Additional Comments From gdr at integrable-solutions dot net  2004-01-19 17:43 -------
Subject: Re:  ICE when mangling template which uses typeof

"ian at wasabisystems dot com" <gcc-bugzilla@gcc.gnu.org> writes:

| Thanks for the pointer.

Thanks to *you* for the quick and extensive answer! 

| 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.

Aha, that is a good point.  I'll change 

   http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00496.html 

to follow your suggestion.

| 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

And in function template return type too.  No?

| 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.

Your guess is basically correct.  After GCC-3.3.3 is out I'll post
extensive documentations for that branch and make it "alive" :-)  

| 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.

Yes, that is true in the particular case of decltype. But we can get
more "advanced" operators.  For example, we may end up having 
__builtin_offsetof(type, member) and type or member are dependent on a
template parameter.

| 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]

for things like __builtin_offsetof, that might be needed.

| 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

Yes I like its simplicity, but it would fail to support things
__builtin_offsetof, no? 

| 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.

Agreed.  Isn't this an issue that should probably be raised on the ABI
reflector or can we just go ahead set precedence?

-- Gaby


-- 


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



More information about the Gcc-bugs mailing list