From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22974 invoked by alias); 26 Mar 2002 10:16:08 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 22943 invoked by uid 71); 26 Mar 2002 10:16:05 -0000 Resent-Date: 26 Mar 2002 10:16:05 -0000 Resent-Message-ID: <20020326101605.22942.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, richard@ex-parrot.com Received:(qmail 22784 invoked by uid 61); 26 Mar 2002 10:15:04 -0000 Message-Id:<20020326101504.22783.qmail@sources.redhat.com> Date: Tue, 26 Mar 2002 02:16:00 -0000 From: richard@ex-parrot.com Reply-To: richard@ex-parrot.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/6057: expression mangling doesn't work for operator new X-SW-Source: 2002-03/txt/msg00965.txt.bz2 List-Id: >Number: 6057 >Category: c++ >Synopsis: expression mangling doesn't work for operator new >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-legal-code >Submitter-Id: net >Arrival-Date: Tue Mar 26 02:16:05 PST 2002 >Closed-Date: >Last-Modified: >Originator: Richard Smith >Release: 3.0.3 and 3.1 branch >Organization: >Environment: linux >Description: The code below produces an ICE in write_expression() in cp/mangle.c whilst trying to mangle helper< sizeof(new T) > (or more specifically, the new part of it). The NEW_EXPR tree node takes three parameters: the placement list (NULL in this example), the type declarator (a template_type_parm corresponding to T), and an initializer list (also NULL in this case). The segfault occurs when it attempts to recursively call write_expression on the NULL placement list. I've looked in the draft Itanium ABI on the codesourcery web page and this gives no guidance as to how this should be handled. I have attached a patch which fixes the problem by mangling calls to new and new[], schematically, as ::= ::= + _ I'm not particularly keen on this mangling of -- I'd prefer something like [random lettter] + E, but this syntax doesn't take any new letters, and uses '_' consistently with, say, . The same problem occurs with function calls, although my patch doesn't address this. It wouldn't surprise me if there wasn't a similar problem with delete and delete[], but I haven't yet been able to coax the compiler into attempting to mangle either of these. I have *not* run a complete bootstrap with the patch, nor run the test-suite with this patch applied. >How-To-Repeat: template struct helper {}; template static void check( helper * ); int main() { check(0); } >Fix: --- mangle.c Fri Mar 22 18:58:01 2002 +++ mangle-patched.c Fri Mar 22 18:57:42 2002 @@ -173,6 +173,7 @@ static void write_bare_function_type PAR static void write_method_parms PARAMS ((tree, int, tree)); static void write_class_enum_type PARAMS ((tree)); static void write_template_args PARAMS ((tree)); +static void write_expression_list PARAMS ((tree)); static void write_expression PARAMS ((tree)); static void write_template_arg_literal PARAMS ((tree)); static void write_template_arg PARAMS ((tree)); @@ -1766,6 +1767,21 @@ write_template_args (args) write_char ('E'); } +/* ::= + _ */ + +static void +write_expression_list (expr_list) + tree expr_list; +{ + while (expr_list) + { + write_expression (TREE_VALUE (expr_list)); + expr_list = TREE_CHAIN (expr_list); + } + + write_char ('_'); +} + /* ::= ::= ::= @@ -1854,6 +1870,13 @@ write_expression (expr) case CONST_CAST_EXPR: write_type (TREE_TYPE (expr)); write_expression (TREE_OPERAND (expr, 0)); + break; + + case NEW_EXPR: + case VEC_NEW_EXPR: + write_expression_list (TREE_OPERAND (expr, 0)); + write_type (TREE_OPERAND (expr, 1)); + write_expression_list (TREE_OPERAND (expr, 2)); break; /* Handle pointers-to-members specially. */ >Release-Note: >Audit-Trail: >Unformatted: