[llvm-bugs] [Bug 38295] New: Breaking difference between __FUNCSIG__ in Clang and MSVC

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 24 17:12:42 PDT 2018


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

            Bug ID: 38295
           Summary: Breaking difference between __FUNCSIG__ in Clang and
                    MSVC
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: charles.milette at gmail.com
                CC: llvm-bugs at lists.llvm.org

In Clang, __FUNCSIG__ seems to be defined as a static const char array. In
MSVC, the developer documentation defines it as a string literal. (see
https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros#microsoft-specific-predefined-macros)

This might seem like a minor difference at first, but makes the following
snippet compile on MSVC but not Clang:

    #include <iostream>

    #define _UNICODE
    #include <tchar.h>

    int main()
    {
        std::wcout << _T(__FUNCSIG__);
    }

Since MSVC uses a string literal, this will expand in L"int __cdecl
main(void)", but with Clang it will expand to L__FUNCSIG__ and it will be
unable to resolve the symbol name, as shown by the compiler output:

    sample.cpp:9:16: error: use of undeclared identifier 'L__FUNCSIG__'
            std::wcout << _T(__FUNCSIG__);
                          ^
    C:\Program Files (x86)\Windows
Kits\10\Include\10.0.17134.0\ucrt\tchar.h:2427:21: note: expanded from macro
'_T'
    #define _T(x)       __T(x)
                        ^
    C:\Program Files (x86)\Windows
Kits\10\Include\10.0.17134.0\ucrt\tchar.h:190:21: note: expanded from macro
'__T'
    #define __T(x)      L ## x
                        ^
    <scratch space>:55:1: note: expanded from here
    L__FUNCSIG__
    ^
    1 error generated.

-- 
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/20180725/005d14b7/attachment-0001.html>


More information about the llvm-bugs mailing list