public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: richard@ex-parrot.com To: gcc-gnats@gcc.gnu.org Subject: c++/6057: expression mangling doesn't work for operator new Date: Tue, 26 Mar 2002 02:16:00 -0000 [thread overview] Message-ID: <20020326101504.22783.qmail@sources.redhat.com> (raw) >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 <expression> ::= <new operator-name> <placement expression-list> <type> <initializer expression-list> <expression-list> ::= <expression>+ _ I'm not particularly keen on this mangling of <expression-list> -- I'd prefer something like [random lettter] <expression>+ E, but this syntax doesn't take any new letters, and uses '_' consistently with, say, <array-type>. 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 <unsigned int> struct helper {}; template <class T> static void check( helper<sizeof(new T)> * ); int main() { check<int>(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'); } +/* <expression-list> ::= <expression>+ _ */ + +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 ('_'); +} + /* <expression> ::= <unary operator-name> <expression> ::= <binary operator-name> <expression> <expression> ::= <expr-primary> @@ -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:
next reply other threads:[~2002-03-26 10:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-03-26 2:16 richard [this message] 2002-03-26 10:40 mmitchel 2002-09-13 7:28 nathan 2002-09-13 9:46 Richard Smith
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020326101504.22783.qmail@sources.redhat.com \ --to=richard@ex-parrot.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).