From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19551 invoked by alias); 9 Aug 2004 02:40:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 19521 invoked by alias); 9 Aug 2004 02:40:22 -0000 Date: Mon, 09 Aug 2004 02:40:00 -0000 Message-ID: <20040809024022.19520.qmail@sourceware.org> From: "giovannibajo at libero dot it" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20030603112812.11078.jtotland1@chello.no> References: <20030603112812.11078.jtotland1@chello.no> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/11078] [ABI] ICE in write_type with typeof and templates X-Bugzilla-Reason: CC X-SW-Source: 2004-08/txt/msg00617.txt.bz2 List-Id: ------- 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 > typeof(T1() + T2()) add(T1 a, T2 b) { return a+b; } > static double foo = add(3.1, 'c'); > > When mangling add(double, char), we need to mangle the > return type. The mangling ABI requires this to be a . If we are > going to mangle this using typeof, then we need to be able to use > an in a . > 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 nested within , through the IXE production. I see the problem though. Something like this would suffice: ::= ::= Y 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 as an > . Since typeof only cares about the types of its > arguments, I think we can get away with representing a type using > the existing L 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 , 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