<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-cl /MDd fails to compile vector with a custom allocator"
   href="https://bugs.llvm.org/show_bug.cgi?id=35483">35483</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-cl /MDd fails to compile vector with a custom allocator
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>veronika.levkevich@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang-cl.exe fails to compile std::vector with a custom allocator when /MDd is
provided as an argument. The issue seems to be triggered by the _DEBUG define.

Code sample to reproduce the issue:
===================
#include <vector>
template<typename T>
  class fuzzer_allocator: public std::allocator<T> {
    public:
      template<class Other>
      struct rebind { typedef fuzzer_allocator<Other> other;  };
  };
int some_func() {
  std::vector<int, fuzzer_allocator<int>> v;
  return v.size();
}
===================

"clang-cl.exe /MDd repro.cc" gives the following output:

In file included from .\repro.cc:2:
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\vector(555,12): 
error: no matching constructor for initialization of
'std::_Vector_alloc<std::_Vec_base_types<int,
      (anonymous namespace)::fuzzer_allocator<int> > >::_Alproxy' (aka
'(anonymous namespace)::fuzzer_allocator<std::_Container_proxy>')
                _Alproxy _Proxy_allocator(_Getal());
                         ^                ~~~~~~~~
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\vector(506,3): 
note: in instantiation of member function
'std::_Vector_alloc<std::_Vec_base_types<int,
      (anonymous namespace)::fuzzer_allocator<int> > >::_Free_proxy' requested
here
                _Free_proxy();
                ^
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\vector(683,2): 
note: in instantiation of member function
'std::_Vector_alloc<std::_Vec_base_types<int,
      (anonymous namespace)::fuzzer_allocator<int> > >::~_Vector_alloc'
requested here
        vector() _NOEXCEPT_COND(is_nothrow_default_constructible<_Alty>::value)
        ^
.\repro.cc(15,43):  note: in instantiation of member function 'std::vector<int,
(anonymous namespace)::fuzzer_allocator<int> >::vector' requested here
  std::vector<int, fuzzer_allocator<int>> v;
                                          ^
.\repro.cc(7,9):  note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from 'fuzzer_allocator<int>' to 'const
fuzzer_allocator<std::_Container_proxy>' for 1st argument
  class fuzzer_allocator: public std::allocator<T> {
        ^
.\repro.cc(7,9):  note: candidate constructor (the implicit move constructor)
not viable: no known conversion from 'fuzzer_allocator<int>' to
'fuzzer_allocator<std::_Container_proxy>' for 1st argument
.\repro.cc(7,9):  note: candidate constructor (the implicit default
constructor) not viable: requires 0 arguments, but 1 was provided
===================

The same code compiles fine when /MDd is not provided.

OS version: Windows 10 Enterprise 1607
MSVC C++ version: 14.11.25503
clang version 6.0.0 (trunk 318667)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>