[LLVMbugs] [Bug 24161] New: unexpected syntax error: operator[] mistaken for lambda capture

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 16 16:01:50 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24161

            Bug ID: 24161
           Summary: unexpected syntax error: operator[] mistaken for
                    lambda capture
           Product: clang
           Version: 3.4
          Hardware: Macintosh
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sherm1 at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14603
  --> https://llvm.org/bugs/attachment.cgi?id=14603&action=edit
Reproduces unexpected syntax error

Vec is a class that has a default constructor and operator[](int) defined. This
construct (resulting from a macro expansion) fails to compile with clang 3.4
C++11, but succeeds with gcc 4.8.2 and VS2015:

if ((std::abs(((Vec())[0]))/3. > 0))
   printf("hi\n");

The error is:

c++ -std=c++11 crash2.cpp
crash2.cpp:61:28: error: expected variable name or 'this' in lambda capture
list
    if ((std::abs(((Vec())[0]))/3. > 0))
                           ^

Removing the extra set of parentheses around Vec() eliminates the error.

I've attached a complete program that fails to compile.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150716/868a5e9b/attachment.html>


More information about the llvm-bugs mailing list