Uploaded image for project: 'SonarCFamily'
  1. SonarCFamily
  2. CPP-1419

Resolve ambiguity: new-type-id in a new-expression is the longest possible sequence of new-declarators

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.11
    • Component/s: Parser
    • Labels:
      None

      Description

      Currently there are two interpretations of expression

      new A* (B)
      

      This is adressed by CPP98 5.3.4p2:

      The new-type-id in a new-expression is the longest possible sequence of new-declarators. [Note: this prevents ambiguities between declarator operators &, *, [], and their expression counterparts. ] [Example:

      new int * i; // syntax error: parsed as (new int*) i
                   // not as (new int)*i
      

      The * is the pointer declarator and not the multiplication operator. ]

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              evgeny.mandrikov Evgeny Mandrikov
              Reporter:
              evgeny.mandrikov Evgeny Mandrikov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: