This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/5805: [parser] the expression 'new (int*)[10]' should be a syntax error


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]