https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86692

            Bug ID: 86692
           Summary: Too lenient parsing of noptr-new-declarator
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: v.reshetnikov at gmail dot com
  Target Milestone: ---

/******* BEGIN SOURCE *******/
int main() {
    int n = 1;
    auto p = new int[n][2, 3];
}
/******** END SOURCE ********/

This compiles without errors, but `2, 3` is not a constant-expression
(conditional-expression) as required by the grammar production for
noptr-new-declarator in [expr.new]. This leniency has some potential for
confusion as someone could interpret `2, 3` as dimensions of a
multi-dimensional array, rather than the comma operator. For comparison, clang
correctly reports a syntax error here.

Checked in build 9.0.0 20180725 (experimental)

Reply via email to