<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59997>59997</a>
        </td>
    </tr>

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

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          VenoVeno
      </td>
    </tr>
</table>

<pre>
    ***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;
}
```

**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
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsGV1P4zr215iXI0dNQr8eeCgp7KKFuaOhl9035DonqS-OHdlOKS_3t6_suLSFwlxWw1xptKi0qX3s8_1ZZq2oFeIZGZ6T4fyEdW6lzdkdKu3_T5a6fDoj2ax_XZFs3IDSDnDTIndC1cDAatk5oRU4DXzFVI3gVghWd4ZjAjfsAaGQTNXQMmP7zduwCY_CrXTnoNGlqJ6EqpNnXGQwJ4Pte1hZoHW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