[llvm-bugs] [Bug 33733] New: Invalid literal check for macro arguments

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 10 12:03:24 PDT 2017


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

            Bug ID: 33733
           Summary: Invalid literal check for macro arguments
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: j.llvm.org at lorenz-ho.me
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Hi,


Minimal example:

    $ cat main.cpp
    #include <iostream>
    #define macro(x) #x

    int main()
    {
        std::cout << macro("abc"S) << std::endl;
        return 0;
    }


g++ 5.4.0:

    $ g++ -std=c++11 -Wall -Wextra main.cpp -o main
    # (compiles without warnings or errors)
    $ ./main
    "abc"S


clang++ 3.9.1:

    $ clang++ -std=c++11 -Wall -Wextra main.cpp -o main
    main.cpp:6:26: error: invalid suffix on literal; C++11 requires a space
between literal and identifier [-Wreserved-user-defined-literal]
            std::cout << macro("abc"S) << std::endl;


Assumption:

clang++ checks for the space between literal and identifier (it's only a check)
before precompilation, which is probably wrong, because literal evaluation is
not part of the precompiler?


Thanks on advance,
Johannes

-- 
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/20170710/09586f3b/attachment.html>


More information about the llvm-bugs mailing list