This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/5805: [parser] the expression 'new (int*)[10]' should be a syntax error
- From: rodrigc at gcc dot gnu dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, jfranosc at ph dot tum dot de, nobody at gcc dot gnu dot org
- Date: 6 Mar 2002 02:45:53 -0000
- Subject: Re: c++/5805: [parser] the expression 'new (int*)[10]' should be a syntax error
- Reply-to: rodrigc at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, jfranosc at ph dot tum dot de, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Old Synopsis: the expression 'new (int*)[10]' should be a syntax error
New Synopsis: [parser] the expression 'new (int*)[10]' should be a syntax error
State-Changed-From-To: closed->analyzed
State-Changed-By: rodrigc
State-Changed-When: Tue Mar 5 18:45:52 2002
State-Changed-Why:
For the following testcase, bug.c:
int main() {
int** p;
p = new int* [10];
p = new (int*) [10];
}
If compiled with:
g++ bug.cc -> NO ERROR
If compiled with
g++ -pedantic-errors bug.cc
bug.cc:ISO C++ forbids array dimensions with parenthesized type in new
This is apparently a gcc extension.
In parse.y,
/* GNU extension to allow arrays of arbitrary types with
non-constant dimension. */
| '(' type_id ')' '[' expr ']'
{
if (pedantic)
pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
$$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
$$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
$$.new_type_flag = $2.new_type_flag;
}
According to Paolo, the new C++ parser produces the
following error:
bug.cc:4: expected `;'
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5805