public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11078] New: typeof and templates.... internal compiler error
@ 2003-06-03 11:28 jtotland1@chello.no
  2003-06-03 12:03 ` [Bug c++/11078] ICE with typeof and templates reichelt@gcc.gnu.org
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: jtotland1@chello.no @ 2003-06-03 11:28 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: typeof and templates.... internal compiler error
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jtotland1@chello.no
                CC: gcc-bugs@gcc.gnu.org

Tested on debian, with gcc 3.0, 3,2 and 3.3

Here is a short snippet that reproduces the error:

template <class T1, class T2>
typeof(T1() + T2()) add(T1 a, T2 b) { return a+b; }
static double foo = add(3.1, 'c');



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug c++/11078] ICE with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
@ 2003-06-03 12:03 ` reichelt@gcc.gnu.org
  2003-06-14 23:41 ` [Bug c++/11078] ICE in write_type " pinskia@physics.uc.edu
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: reichelt@gcc.gnu.org @ 2003-06-03 12:03 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


reichelt@gcc.gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|0000-00-00 00:00:00         |2003-06-03 12:03:26
               date|                            |
            Summary|typeof and templates....    |ICE with typeof and
                   |internal compiler error     |templates


------- Additional Comments From reichelt@gcc.gnu.org  2003-06-03 12:03 -------
The code crashes since gcc 2.95.x.
The error message on mainline is:

bug.cc:3: internal compiler error: in write_type, at cp/mangle.c:1494
Please submit a full bug report, [etc.]




------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
  2003-06-03 12:03 ` [Bug c++/11078] ICE with typeof and templates reichelt@gcc.gnu.org
@ 2003-06-14 23:41 ` pinskia@physics.uc.edu
  2003-07-20  3:20 ` pinskia at physics dot uc dot edu
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia@physics.uc.edu @ 2003-06-14 23:41 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From pinskia@physics.uc.edu  2003-06-14 23:41 -------
Even 2.91.66 crashes.


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
  2003-06-03 12:03 ` [Bug c++/11078] ICE with typeof and templates reichelt@gcc.gnu.org
  2003-06-14 23:41 ` [Bug c++/11078] ICE in write_type " pinskia@physics.uc.edu
@ 2003-07-20  3:20 ` pinskia at physics dot uc dot edu
  2003-07-30 15:12 ` gccbugs at contacts dot eelis dot net
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-20  3:20 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu dot org


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-20 03:20 -------
*** Bug 11578 has been marked as a duplicate of this bug. ***


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (2 preceding siblings ...)
  2003-07-20  3:20 ` pinskia at physics dot uc dot edu
@ 2003-07-30 15:12 ` gccbugs at contacts dot eelis dot net
  2003-07-30 15:30 ` reichelt at igpm dot rwth-aachen dot de
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: gccbugs at contacts dot eelis dot net @ 2003-07-30 15:12 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From gccbugs at contacts dot eelis dot net  2003-07-30 15:12 -------
The following very similar (though simpler) code produces an ICE in the same
file but on line 1473:

template <class T> typeof(1) f ();
int const x = f<int>();


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (3 preceding siblings ...)
  2003-07-30 15:12 ` gccbugs at contacts dot eelis dot net
@ 2003-07-30 15:30 ` reichelt at igpm dot rwth-aachen dot de
  2003-08-23  0:24 ` dhazeghi at yahoo dot com
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: reichelt at igpm dot rwth-aachen dot de @ 2003-07-30 15:30 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From reichelt at igpm dot rwth-aachen dot de  2003-07-30 15:30 -------
Subject: Re:  ICE in write_type with typeof and templates

On 30 Jul, gccbugs at contacts dot eelis dot net wrote:

> The following very similar (though simpler) code produces an ICE in the same
> file but on line 1473:
> 
> template <class T> typeof(1) f ();
> int const x = f<int>();

That's a different bug which is already fixed since 20030515, whereas
the original one is still not fixed.

Regards,
Volker


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (4 preceding siblings ...)
  2003-07-30 15:30 ` reichelt at igpm dot rwth-aachen dot de
@ 2003-08-23  0:24 ` dhazeghi at yahoo dot com
  2003-09-25  1:33 ` bangerth at dealii dot org
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  0:24 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (5 preceding siblings ...)
  2003-08-23  0:24 ` dhazeghi at yahoo dot com
@ 2003-09-25  1:33 ` bangerth at dealii dot org
  2004-07-26 13:33 ` pinskia at gcc dot gnu dot org
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: bangerth at dealii dot org @ 2003-09-25  1:33 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boris at kolpackov dot net


------- Additional Comments From bangerth at dealii dot org  2003-09-24 23:17 -------
*** Bug 12394 has been marked as a duplicate of this bug. ***


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

* [Bug c++/11078] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (6 preceding siblings ...)
  2003-09-25  1:33 ` bangerth at dealii dot org
@ 2004-07-26 13:33 ` pinskia at gcc dot gnu dot org
  2004-07-31  1:18 ` [Bug c++/11078] [ABI] " giovannibajo at libero dot it
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-26 13:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-26 13:33 -------
*** Bug 16714 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marco at technoboredom dot
                   |                            |net


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (7 preceding siblings ...)
  2004-07-26 13:33 ` pinskia at gcc dot gnu dot org
@ 2004-07-31  1:18 ` giovannibajo at libero dot it
  2004-07-31 10:26 ` giovannibajo at libero dot it
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-31  1:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-07-31 01:18 -------
The segfault should just be a sorry(): we don't currently have a way to mangle 
this in the C++ ABI.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |giovannibajo at libero dot
                   |dot org                     |it
             Status|NEW                         |ASSIGNED
            Summary|ICE in write_type with      |[ABI] ICE in write_type with
                   |typeof and templates        |typeof and templates


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (8 preceding siblings ...)
  2004-07-31  1:18 ` [Bug c++/11078] [ABI] " giovannibajo at libero dot it
@ 2004-07-31 10:26 ` giovannibajo at libero dot it
  2004-07-31 17:33 ` gdr at integrable-solutions dot net
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-31 10:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-07-31 10:26 -------
Ian, what do you suggest here? It might make sense to mangle it as "v17typeofe" 
and "v17typeoft" (we need different mangling for the expression vs type case of 
course). I'm sure there won't be an official ABI mangling of "typeof", 
especially if the C++ committee is going to use "auto" and "decltype", so we 
could probably go ahead and use the vendor extension.

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (9 preceding siblings ...)
  2004-07-31 10:26 ` giovannibajo at libero dot it
@ 2004-07-31 17:33 ` gdr at integrable-solutions dot net
  2004-08-03 20:57 ` ian at wasabisystems dot com
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-07-31 17:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-07-31 17:33 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:

| Ian, what do you suggest here? It might make sense to mangle it as "v17typeofe" 
| and "v17typeoft" (we need different mangling for the expression vs type case of 
| course). I'm sure there won't be an official ABI mangling of "typeof", 
| especially if the C++ committee is going to use "auto" and "decltype", so we 
| could probably go ahead and use the vendor extension.

Even if/when the C++ standards committee decides on decltype, we still
need something for typeof or similar operator.

-- Gaby


-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (10 preceding siblings ...)
  2004-07-31 17:33 ` gdr at integrable-solutions dot net
@ 2004-08-03 20:57 ` ian at wasabisystems dot com
  2004-08-03 21:28 ` boris at kolpackov dot net
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: ian at wasabisystems dot com @ 2004-08-03 20:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ian at wasabisystems dot com  2004-08-03 20:57 -------
It would be nice to be able to use something as simple as v16typeof, or
v17typeofe/v17typeoft, but it is not.  The problem is that typeof can introduce
expressions in cases where the mangling ABI does not permit them.  Consider the
test case in this PR:

template <class T1, class T2>
typeof(T1() + T2()) add(T1 a, T2 b) { return a+b; }
static double foo = add(3.1, 'c');

When mangling add<double, char>(double, char), we need to mangle the return
type.  The mangling ABI requires this to be a <type>.  If we are going to mangle
this using typeof, then we need to be able to use an <expression> in a <type>. 
But the mangling ABI does not provide any mechanism for that.

However, I note that we don't actually have to use typeof when mangling this
name.  When the compiler sees the template arguments, it can always resolve the
typeof down to a basic type.  Would it be reasonable to address the issue in
that way?

In fact, in general the compiler can resolve typeof.  In what cases will it not
be able to?

If there a case in which the compiler can not resolve typeof, I think we should
use the vendor extended operator syntax.  Separating typeoft and typeofe doesn't
actually work, because the parameter to typeof may itself be an expression
involving types.  What we need is a way to express a <type> as an
<expr-primary>.  Since typeof only cares about the types of its arguments, I
think we can get away with representing a type using the existing L <type>
<value> E syntax, and always using the value "0".

But I think we need some examples.  My current guess is that the example in this
PR should not require us to mangle typeof.  Any thoughts on this?

If it does require us to mangle typeof, then we need to decide how to express
typeof in a <type>, which will require an ABI extension.

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (11 preceding siblings ...)
  2004-08-03 20:57 ` ian at wasabisystems dot com
@ 2004-08-03 21:28 ` boris at kolpackov dot net
  2004-08-03 21:40 ` bangerth at dealii dot org
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: boris at kolpackov dot net @ 2004-08-03 21:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From boris at kolpackov dot net  2004-08-03 21:27 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

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

> In fact, in general the compiler can resolve typeof.  
> In what cases will it not be able to?

The only thing I can think of is code like this:

struct
{
} a;

static void
fa (typeof (a)&)
{
}

struct
{
} b;

static void
fb (typeof (b)&)
{
}


void
f ()
{
  fa (a);
  fb (b);
}


It compiles with g++ 3.4.1. nm shows the following:

0000000c T f()
00000000 t fa(._0&)
00000006 t fb(._1&)
00000000 B a
00000001 B b

Which suggest that gcc assigns internal names even to anonymous
types. So I think it's true that any typeof-expression can be 
reduced to a type-name.



-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (12 preceding siblings ...)
  2004-08-03 21:28 ` boris at kolpackov dot net
@ 2004-08-03 21:40 ` bangerth at dealii dot org
  2004-08-09  2:40 ` giovannibajo at libero dot it
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: bangerth at dealii dot org @ 2004-08-03 21:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-03 21:40 -------
Fortunately, the example in comment #12 just became illegal on mainline. 
We now get this: 
x.cc:3: error: non-local variable `<anonymous struct> a' uses anonymous type 
x.cc:12: error: non-local variable `<anonymous struct> b' uses anonymous type 
 
That's good, because I can think of all kinds of unpleasant surprises if 
you declare such variables in header files, where they may get different 
internal names dependending on the translation units that includes them. 
If such names are taken over into mangled names, this is asking for big 
trouble. 
 
W. 

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (13 preceding siblings ...)
  2004-08-03 21:40 ` bangerth at dealii dot org
@ 2004-08-09  2:40 ` giovannibajo at libero dot it
  2004-08-09 13:56 ` ian at wasabisystems dot com
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-09  2:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-08-09 02:40 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

ian at wasabisystems dot com wrote:

> The problem is that typeof can introduce expressions in cases where the
> mangling ABI does not permit them.

> template <class T1, class T2>
> typeof(T1() + T2()) add(T1 a, T2 b) { return a+b; }
> static double foo = add(3.1, 'c');
>
> When mangling add<double, char>(double, char), we need to mangle the
> return  type.  The mangling ABI requires this to be a <type>.  If we are
> going to mangle this using typeof, then we need to be able to use
> an <expression> in a <type>.
> But the mangling ABI does not provide any mechanism for that.

OK, there is no way to use it *directly*, but that would not make sense.
Instead, there are already <expression> nested within <type>, through the
IX<expression>E production.
I see the problem though. Something like this would suffice:

<type> ::= <typeof-type>
<typeof-type> ::= Y <expression> E

but this is a real ABI extension. Do we want this? I definitely *do* want it,
much better than an ICE or erroring out.
Using the built-in extension "u6typeof" does seem worse in the longer run since
it's clearly an abuse of it.

> However, I note that we don't actually have to use typeof when
> mangling this name.  When the compiler sees the template arguments,
> it can always resolve the typeof down to a basic type.
> Would it be reasonable to address the issue in that way?

No. There are many expressions that *could* be folded and simplified while
mangling the name (within a template argument), but the ABI explicitally
forbids this. Quoting: "Note that the expression is mangled without constant
folding or other simplification, and without parentheses, which are implicit in
the prefix representation. Except for the parentheses, therefore, it represents
the source token stream".

> What we need is a way to express a <type> as an
> <expr-primary>.  Since typeof only cares about the types of its
> arguments, I think we can get away with representing a type using
> the existing L <type> <value> E syntax, and always using the value "0".

I don't follow. We are trying to mangle a *type*, so we need to represent
typeof() in the context of <type>, not viceversa.

Also, notice that the example of this PR needs also *another* ABI extension,
see PR 6424 where I am going to add a comment about this.

Giovanni Bajo




-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (14 preceding siblings ...)
  2004-08-09  2:40 ` giovannibajo at libero dot it
@ 2004-08-09 13:56 ` ian at wasabisystems dot com
  2004-08-09 14:14 ` gdr at integrable-solutions dot net
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: ian at wasabisystems dot com @ 2004-08-09 13:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ian at wasabisystems dot com  2004-08-09 13:55 -------
OK, if we need to be able to express typeof() when describing a return type,
then I agree that we need an extension to <type>.  I think your suggestion of
<type> ::= Y <expression> E is the best one.

The issue of <type> within <expr-primary> is for cases like c<typeof(int*)>. 
The current compiler treats that as being identical to c<int*>.  If that is
wrong, then we need to use the proposed Y <expression> E extension, and we need
to have <type> appear in an <expression>, which is currently not directly
possible.  Rather than introduce another extension, I propose mangling that as
1cIYLPi0EEE -- that is, we express (int*) as a constant of type (int*) and value
0.  I guess the drawback is that this means that c<typeof(int)> and c<typeof(0)>
might have identical manglings.  If that is not permissible, then we need
another extension, and we as well reuse 'Y', as in expression ::= Y <type>. 
Then c<typeof(int)> would be mangled as 1cIYXYiEEE.

If somebody gets a patch into the compiler, I will change the libiberty demangler.

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (15 preceding siblings ...)
  2004-08-09 13:56 ` ian at wasabisystems dot com
@ 2004-08-09 14:14 ` gdr at integrable-solutions dot net
  2004-08-09 14:39 ` giovannibajo at libero dot it
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-09 14:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-08-09 14:14 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

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

[...]

| possible.  Rather than introduce another extension, I propose mangling that as
| 1cIYLPi0EEE -- that is, we express (int*) as a constant of type (int*) and value
| 0.  I guess the drawback is that this means that c<typeof(int)> and c<typeof(0)>
| might have identical manglings.  If that is not permissible, then we need

I object to that deviation.  For the same reasons we don't "fold"
expressions, we should not be doing that transmutation.

-- Gaby


-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (16 preceding siblings ...)
  2004-08-09 14:14 ` gdr at integrable-solutions dot net
@ 2004-08-09 14:39 ` giovannibajo at libero dot it
  2004-08-09 14:47 ` ian at wasabisystems dot com
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-09 14:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-08-09 14:39 -------
(In reply to comment #15)

> The issue of <type> within <expr-primary> is for cases like c<typeof(int*)>. 
> The current compiler treats that as being identical to c<int*>.  

Question: do we really need typeof(<type>)? It does not make sense to me. typeof
(type) is always "type", so I cannot see why we should wrap it within a typeof. 
If GCC currently accepts this, we could easily flag it as an error and reject 
it. Gaby?

After this, we don't need anything more than the "<type> ::= Y <expression> E" 
extension.

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (17 preceding siblings ...)
  2004-08-09 14:39 ` giovannibajo at libero dot it
@ 2004-08-09 14:47 ` ian at wasabisystems dot com
  2004-08-09 15:05 ` giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: ian at wasabisystems dot com @ 2004-08-09 14:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ian at wasabisystems dot com  2004-08-09 14:47 -------
typeof(int*) has been in the gcc docs for ages.  See the gcc docs for examples
where it is useful.

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (18 preceding siblings ...)
  2004-08-09 14:47 ` ian at wasabisystems dot com
@ 2004-08-09 15:05 ` giovannibajo at libero dot it
  2004-08-09 17:11 ` gdr at integrable-solutions dot net
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-09 15:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-08-09 15:05 -------
I went and read the docs, and still fail to see how it can be useful. But you 
have a point in that we cannot probably drop support for it so easily. 

What about stripping out typeof(type) while mangling, then? It really does not 
buy us anything. Plus, I don't think we want to say that the following 
declarations are declaring two different functions:

void foo(typeof(int*));
void foo(int*);

or these:

void bar(typeof(typeof(char*) [4]) blah);
void bar(char *blah[4]);

In other words, we can easily strip typeof(type) while mangling, and encoding 
typeof(expr) as Y <expression> E. 

If we agree on this, I can prepare a little patch in the following days (even 
if I am not sure it will be accepted, but hey).

-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (19 preceding siblings ...)
  2004-08-09 15:05 ` giovannibajo at libero dot it
@ 2004-08-09 17:11 ` gdr at integrable-solutions dot net
  2004-08-09 17:31 ` gdr at integrable-solutions dot net
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-09 17:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-08-09 17:11 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:

| (In reply to comment #15)
| 
| > The issue of <type> within <expr-primary> is for cases like c<typeof(int*)>. 
| > The current compiler treats that as being identical to c<int*>.  
| 
| Question: do we really need typeof(<type>)? 

At some point, the decltype/auto proposal considered that possibility.
It has the advantage that it provides a convenient way of having an
unnamed typedef and can be used as a simple-type-specifier.
Subsequent refeniment did no longer mention it, but nothing is
definitive. 

| It does not make sense to me. 

It does make sense; see above.

| typeof (type) is always "type", so I cannot see why we should wrap
| it within a typeof. 

It does not bring much when "type" is a simple-typecifier.  But, it
has some value when you consider more elaborated type-specifier.

| If GCC currently accepts this, we could
| easily flag it as an error and reject it. Gaby?

I have no strong opinion but I would lean toward supporting 
typeof(type), unless it is proven to be really useless.

-- Gaby


-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (20 preceding siblings ...)
  2004-08-09 17:11 ` gdr at integrable-solutions dot net
@ 2004-08-09 17:31 ` gdr at integrable-solutions dot net
  2004-08-10  0:49 ` giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-09 17:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-08-09 17:31 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:

| I went and read the docs, and still fail to see how it can be useful. But you 
| have a point in that we cannot probably drop support for it so easily. 
| 
| What about stripping out typeof(type) while mangling, then? It really does not 
| buy us anything. Plus, I don't think we want to say that the following 
| declarations are declaring two different functions:
| 
| void foo(typeof(int*));
| void foo(int*);
| 
| or these:
| 
| void bar(typeof(typeof(char*) [4]) blah);
| void bar(char *blah[4]);

As I said before, the problem is inexistent for ordinary functions
because we don't care about the retun type of those.  
The issue is with function templates, and there we do care.
So I don't believe in arguments based on ordinary functions to strip
out typeof. 

| 
| In other words, we can easily strip typeof(type) while mangling, and encoding 
| typeof(expr) as Y <expression> E. 
| 
| If we agree on this,

I don't think we reach a conclusion based on the arguments you
developed above.

-- Gaby


-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (21 preceding siblings ...)
  2004-08-09 17:31 ` gdr at integrable-solutions dot net
@ 2004-08-10  0:49 ` giovannibajo at libero dot it
  2004-08-10  1:35 ` gdr at integrable-solutions dot net
  2004-11-10  2:00 ` pinskia at gcc dot gnu dot org
  24 siblings, 0 replies; 26+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-10  0:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-08-10 00:49 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

gdr at integrable-solutions dot net wrote:

>> buy us anything. Plus, I don't think we want to say that the
>> following declarations are declaring two different functions:
>>
>> void foo(typeof(int*));
>> void foo(int*);
>>
>> or these:
>>
>> void bar(typeof(typeof(char*) [4]) blah);
>> void bar(char *blah[4]);
>
> As I said before, the problem is inexistent for ordinary functions
> because we don't care about the retun type of those.
> The issue is with function templates, and there we do care.
> So I don't believe in arguments based on ordinary functions to strip
> out typeof.

I am not speaking of return types (only) here. I am speaking of the mangling of
typeof(<type>), wherever it appears in a mangled part of a function signature.
Anyway, in case I am missing something, the same argument can be brought for
template functions. I suggest we mangle each element in the following couple
(or better -- each instantiation with the same set of arguments) with the same
name:

template <int> void foo(typeof(int*));
template <int> void foo(int*);

template <class T> void foo(typeof(typeof(T*)[4]) blah);
template <class T> void foo(T *blah[4]);

My conclusion is the same as before:

>> In other words, we can easily strip typeof(type) while mangling, and
>> encoding typeof(expr) as Y <expression> E.

Giovanni Bajo




-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (22 preceding siblings ...)
  2004-08-10  0:49 ` giovannibajo at libero dot it
@ 2004-08-10  1:35 ` gdr at integrable-solutions dot net
  2004-11-10  2:00 ` pinskia at gcc dot gnu dot org
  24 siblings, 0 replies; 26+ messages in thread
From: gdr at integrable-solutions dot net @ 2004-08-10  1:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at integrable-solutions dot net  2004-08-10 01:35 -------
Subject: Re:  [ABI] ICE in write_type with typeof and templates

"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:

| Subject: Re:  [ABI] ICE in write_type with typeof and templates
| 
| gdr at integrable-solutions dot net wrote:
| 
| >> buy us anything. Plus, I don't think we want to say that the
| >> following declarations are declaring two different functions:
| >>
| >> void foo(typeof(int*));
| >> void foo(int*);
| >>
| >> or these:
| >>
| >> void bar(typeof(typeof(char*) [4]) blah);
| >> void bar(char *blah[4]);
| >
| > As I said before, the problem is inexistent for ordinary functions
| > because we don't care about the retun type of those.
| > The issue is with function templates, and there we do care.
| > So I don't believe in arguments based on ordinary functions to strip
| > out typeof.
| 
| I am not speaking of return types (only) here. I am speaking of the mangling of
| typeof(<type>), wherever it appears in a mangled part of a function signature.

The issue is of interest only for function templates.  For
non-templates, it is moot.  It is moot for non-templates because we
always use the normal form of their signatures.  
For templates, we use their token streams, where the problem come to
interest. 

| Anyway, in case I am missing something, the same argument can be brought for
| template functions. I suggest we mangle each element in the following couple
| (or better -- each instantiation with the same set of arguments) with the same
| name:
| 
| template <int> void foo(typeof(int*));
| template <int> void foo(int*);
| 
| template <class T> void foo(typeof(typeof(T*)[4]) blah);
| template <class T> void foo(T *blah[4]);

These two declarations are not equivalent, as the template parameter
in the first declaration appears in non-deducible context whereas it
is deducible in the second.  If they are not equivalent, you cannot
decide that they will mangle the same, for the very same reasons I
outlined before.  And it is very easy to construct examples where you
screw up things, just like in my previous messages.  If you insist in
mangling them the same, there are modifications to the current
semantics you ought to make before getting to that point. 
Also notice that currently, we have no problem mangling the above.

[...]

| My conclusion is the same as before:
| 
| >> In other words, we can easily strip typeof(type) while mangling, and
| >> encoding typeof(expr) as Y <expression> E.


In the current state of affairs, that would be an ill-informed thing
to do.  And I would strongly advise against.

-- Gaby


-- 


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


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

* [Bug c++/11078] [ABI] ICE in write_type with typeof and templates
  2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
                   ` (23 preceding siblings ...)
  2004-08-10  1:35 ` gdr at integrable-solutions dot net
@ 2004-11-10  2:00 ` pinskia at gcc dot gnu dot org
  24 siblings, 0 replies; 26+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-10  2:00 UTC (permalink / raw)
  To: gcc-bugs


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

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kong at ece dot ucdavis dot
                   |                            |edu


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


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

end of thread, other threads:[~2004-11-10  2:00 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-03 11:28 [Bug c++/11078] New: typeof and templates.... internal compiler error jtotland1@chello.no
2003-06-03 12:03 ` [Bug c++/11078] ICE with typeof and templates reichelt@gcc.gnu.org
2003-06-14 23:41 ` [Bug c++/11078] ICE in write_type " pinskia@physics.uc.edu
2003-07-20  3:20 ` pinskia at physics dot uc dot edu
2003-07-30 15:12 ` gccbugs at contacts dot eelis dot net
2003-07-30 15:30 ` reichelt at igpm dot rwth-aachen dot de
2003-08-23  0:24 ` dhazeghi at yahoo dot com
2003-09-25  1:33 ` bangerth at dealii dot org
2004-07-26 13:33 ` pinskia at gcc dot gnu dot org
2004-07-31  1:18 ` [Bug c++/11078] [ABI] " giovannibajo at libero dot it
2004-07-31 10:26 ` giovannibajo at libero dot it
2004-07-31 17:33 ` gdr at integrable-solutions dot net
2004-08-03 20:57 ` ian at wasabisystems dot com
2004-08-03 21:28 ` boris at kolpackov dot net
2004-08-03 21:40 ` bangerth at dealii dot org
2004-08-09  2:40 ` giovannibajo at libero dot it
2004-08-09 13:56 ` ian at wasabisystems dot com
2004-08-09 14:14 ` gdr at integrable-solutions dot net
2004-08-09 14:39 ` giovannibajo at libero dot it
2004-08-09 14:47 ` ian at wasabisystems dot com
2004-08-09 15:05 ` giovannibajo at libero dot it
2004-08-09 17:11 ` gdr at integrable-solutions dot net
2004-08-09 17:31 ` gdr at integrable-solutions dot net
2004-08-10  0:49 ` giovannibajo at libero dot it
2004-08-10  1:35 ` gdr at integrable-solutions dot net
2004-11-10  2:00 ` 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).