Skip to content

rejects-valid if parenthesized temporary is followed by array indexing #20723

@zygoloid

Description

@zygoloid
mannequin
Bugzilla Link 20349
Version unspecified
OS Linux
CC @DougGregor

Extended Description

Clang rejects this valid code in C++11 onwards:

  struct S { S operator[](int); S operator()(); };
  int n;
  void f() { (S())[n](); }

The problem is that we commit to handling the [ as the start of a lambda-expression too early.

We also incorrectly reject the above testcase in Objective-C++ mode, because we think the [ is the start of a message send expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11clang:frontendLanguage frontend issues, e.g. anything involving "Sema"cwg-issueAn issue that was filed to the Core Working Groupobjective-c++rejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions