[LLVMbugs] [Bug 11261] New: Compiler error when using "_Generic" identifier in C++ source code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Oct 28 15:11:40 PDT 2011


           Summary: Compiler error when using "_Generic" identifier in C++
                    source code
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: max at quendi.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

When compiling code with clang++ 3.0 (as shipped with Apple XCode 4.2) that
contains _Generic, an error is raised, like this:

test.cc:5:6: error: expected unqualified-id
        int _Generic = 0;

After some googling around, this seems to be related to the "C1X generic
selections" extension (see
However, I could not find further information on this, and it is not clear to
me whether this is part of C++11, or of a future extension of the C++ standard.

If this error really is intentional behavior, then please change the warning to
something more helpful, like "_Generic is a C1X reserved keyword". 

But personally I'd prefer if using _Generic was again made possible for code
that does not explicitly request C1X extensions, as "legacy code" is using

For reference, this was with
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin10.8.0
Thread model: posix

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list