public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13740] New: ICE when mangling template which uses typeof
@ 2004-01-19 14:54 ian at airs dot com
  2004-01-19 15:05 ` [Bug c++/13740] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ian at airs dot com @ 2004-01-19 14:54 UTC (permalink / raw)
  To: gcc-bugs

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.

Note that the current mangling ABI doesn't specify how to handle typeof, which
is after all a GNU extension.  I think that mangling this name will require an
extension to the mangling ABI.  I think this could be handled by adding a new
unary operator, ty, which represents typeof applied to its argument.

Alternatively, the use of typeof could be replaced by the resulting type when
mangling the template name.  I suppose that would some types of templates
equivalent although they didn't look equivalent.  It's hard to know how to
handle an extension like this.

-- 
           Summary: ICE when mangling template which uses typeof
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
@ 2004-01-19 15:05 ` pinskia at gcc dot gnu dot org
  2004-01-19 16:17 ` gdr at integrable-solutions dot net
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-19 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-19 15:05 -------
Confirmed, I almost want to say this is a dup of bug 11078.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-19 15:05:22
               date|                            |


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
  2004-01-19 15:05 ` [Bug c++/13740] " pinskia at gcc dot gnu dot org
@ 2004-01-19 16:17 ` gdr at integrable-solutions dot net
  2004-01-19 16:42 ` ian at wasabisystems dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-01-19 16:17 UTC (permalink / raw)
  To: gcc-bugs


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

-- Gaby


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
  2004-01-19 15:05 ` [Bug c++/13740] " pinskia at gcc dot gnu dot org
  2004-01-19 16:17 ` gdr at integrable-solutions dot net
@ 2004-01-19 16:42 ` ian at wasabisystems dot com
  2004-01-19 17:43 ` gdr at integrable-solutions dot net
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ian at wasabisystems dot com @ 2004-01-19 16:42 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
                   ` (2 preceding siblings ...)
  2004-01-19 16:42 ` ian at wasabisystems dot com
@ 2004-01-19 17:43 ` gdr at integrable-solutions dot net
  2004-01-19 18:01 ` ian at wasabisystems dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-01-19 17:43 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
                   ` (3 preceding siblings ...)
  2004-01-19 17:43 ` gdr at integrable-solutions dot net
@ 2004-01-19 18:01 ` ian at wasabisystems dot com
  2004-01-19 18:16 ` gdr at integrable-solutions dot net
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ian at wasabisystems dot com @ 2004-01-19 18:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ian at wasabisystems dot com  2004-01-19 18:01 -------
Subject: Re:  ICE when mangling template which uses typeof

"gdr at integrable-solutions dot net" <gcc-bugzilla@gcc.gnu.org> writes:

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

Yes, true.

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

I don't see why.  It ought to support anythning which Nathan's
suggestion would support.  For example, __builtin_offsetof(foo, bar)
might be
    Y18__builtin_offsetof3foo3barE
and __builtin_offsetof(foo<int>, bar) might be
    Y18__builtin_offsetof3fooIiE3barE

In general, this approach would let you qualify the type using
anything which can appear as a template parameter, which includes any
type or expression.  What else would you like to see here?

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

I don't know.  You would have to ask somebody at CodeSourcery what
they think.

Ian


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
                   ` (4 preceding siblings ...)
  2004-01-19 18:01 ` ian at wasabisystems dot com
@ 2004-01-19 18:16 ` gdr at integrable-solutions dot net
  2004-07-13 19:10 ` jens dot maurer at gmx dot net
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-01-19 18:16 UTC (permalink / raw)
  To: gcc-bugs


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

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

[...]

| > | 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? 
| 
| I don't see why.  It ought to support anythning which Nathan's
| suggestion would support.  For example, __builtin_offsetof(foo, bar)
| might be
|     Y18__builtin_offsetof3foo3barE
| and __builtin_offsetof(foo<int>, bar) might be
|     Y18__builtin_offsetof3fooIiE3barE
| 
| In general, this approach would let you qualify the type using
| anything which can appear as a template parameter, which includes any
| type or expression.  What else would you like to see here?

Nothing.  Your example washed my confusion.  Thanks!
I like your suggestion better.

-- Gaby


-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
                   ` (5 preceding siblings ...)
  2004-01-19 18:16 ` gdr at integrable-solutions dot net
@ 2004-07-13 19:10 ` jens dot maurer at gmx dot net
  2004-10-05 11:36 ` pinskia at gcc dot gnu dot org
  2004-10-05 14:22 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jens dot maurer at gmx dot net @ 2004-07-13 19:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jens dot maurer at gmx dot net  2004-07-13 19:10 -------
*** Bug 14691 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jens dot maurer at gmx dot
                   |                            |net


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
                   ` (6 preceding siblings ...)
  2004-07-13 19:10 ` jens dot maurer at gmx dot net
@ 2004-10-05 11:36 ` pinskia at gcc dot gnu dot org
  2004-10-05 14:22 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-05 11:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-05 11:35 -------
*** Bug 17839 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkouroun at mailbox dot gr


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/13740] ICE when mangling template which uses typeof
  2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
                   ` (7 preceding siblings ...)
  2004-10-05 11:36 ` pinskia at gcc dot gnu dot org
@ 2004-10-05 14:22 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-05 14:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-05 14:22 -------
*** Bug 17842 has been marked as a duplicate of this bug. ***

-- 


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-10-05 14:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 14:54 [Bug c++/13740] New: ICE when mangling template which uses typeof ian at airs dot com
2004-01-19 15:05 ` [Bug c++/13740] " pinskia at gcc dot gnu dot org
2004-01-19 16:17 ` gdr at integrable-solutions dot net
2004-01-19 16:42 ` ian at wasabisystems dot com
2004-01-19 17:43 ` gdr at integrable-solutions dot net
2004-01-19 18:01 ` ian at wasabisystems dot com
2004-01-19 18:16 ` gdr at integrable-solutions dot net
2004-07-13 19:10 ` jens dot maurer at gmx dot net
2004-10-05 11:36 ` pinskia at gcc dot gnu dot org
2004-10-05 14:22 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).