[clang] no viable conversion from 'ATL::CStringA' (aka 'CStringT<char, StrTraitATL<char, ChTraitsCRT<>>>') to 'std::string' (aka 'basic_string<char>')

I’m not expecting a solution to change the source. Make Clang parse the Source without modifying.

TestClass.cpp

#include <atlstr.h>
#include <string>

using namespace std;

void testMe(CStringA dCount) {
    std::string str = dCount;
}

int main() {
    return 0;

    CStringA count;
    testMe(count);
}

Command to run

clang TestClass.cpp -m32 -w -v

Verbose Output:

clang version 12.0.0
Target: i386-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM-12\bin
 "C:\\Program Files\\LLVM-12\\bin\\clang.exe" -cc1 -triple i386-pc-windows-msvc16.0.30319 -emit-obj -mrelax-all -mincremental-linker-compatible --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name TestClass.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu pentium4 -tune-cpu generic -v -resource-dir "C:\\Program Files\\LLVM-12\\lib\\clang\\12.0.0" -internal-isystem "C:\\Program Files\\LLVM-12\\lib\\clang\\12.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\ATLMFC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include" -w -fdeprecated-macro -fdebug-compilation-dir "C:\\Users\\Administrator\\Documents\\Veno\\CodeChecker" -ferror-limit 19 -fmessage-length=211 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=16.0.30319 -std=c++11 -fno-threadsafe-statics -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\TestClass-866d86.o" -x c++ TestClass.cpp
clang -cc1 version 12.0.0 based upon LLVM 12.0.0 default target x86_64-pc-windows-msvc
ignoring duplicate directory "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE"
ignoring duplicate directory "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE"
ignoring duplicate directory "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include"
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM-12\lib\clang\12.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE
 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE
 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include
End of search list.
TestClass.cpp:7:17: error: no viable conversion from 'ATL::CStringA' (aka 'CStringT<char, StrTraitATL<char, ChTraitsCRT<>>>') to 'std::string' (aka 'basic_string<char>')
    std::string str = dCount;
                ^     ~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xstring:541:2: note: candidate constructor not viable: no known conversion from 'ATL::CStringA'
      (aka 'CStringT<char, StrTraitATL<char, ChTraitsCRT<>>>') to 'const std::basic_string<char>::_Myt &' (aka 'const basic_string<char> &') for 1st argument
        basic_string(const _Myt& _Right)
        ^
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xstring:590:2: note: candidate constructor not viable: no known conversion from 'ATL::CStringA'
      (aka 'CStringT<char, StrTraitATL<char, ChTraitsCRT<>>>') to 'const char *' for 1st argument
        basic_string(const _Elem *_Ptr)
        ^
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xstring:700:2: note: candidate constructor not viable: no known conversion from 'ATL::CStringA'
      (aka 'CStringT<char, StrTraitATL<char, ChTraitsCRT<>>>') to 'std::basic_string<char>::_Myt &&' (aka 'basic_string<char> &&') for 1st argument
        basic_string(_Myt&& _Right)
        ^
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xstring:554:11: note: explicit constructor is not a candidate
        explicit basic_string(const _Alloc& _Al)
                 ^
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\cstringt.h:950:2: note: candidate function
        operator CSimpleStringT<BaseType, !_CSTRING_IMPL_::_MFCDLLTraitsCheck<BaseType, StringTraits>::c_bIsMFCDLLTraits >&()
        ^
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE\atlsimpstr.h:401:2: note: candidate function
        operator PCXSTR() const throw()
        ^
1 error generated.

But if i compile with MSVC Compiler from command line. Everything works fine.

cl TestClass.cpp /EHsc

Tried to Compile C++ Source with Clang Compiler. But it results in an error relating to no viable conversion from ATL::CStringA to std::string.

OS : Windows 10
Clang Version : 12.0.0
Target : x86_64-pc-windows-msvc