<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 - Diagnostic withholds number of line responsible for bad template instantiation"
   href="https://bugs.llvm.org/show_bug.cgi?id=46000">46000</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Diagnostic withholds number of line responsible for bad template instantiation
          </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>Linux
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>tonyelewis@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This code has a function template that wraps emplace_back() for vector<int> and
then code that erroneously attempts to instantiate it to emplace_back a
nullptr:


#include <vector>

template <typename... Ts>
decltype(auto) int_vec_emplace_back_wrapper(std::vector<int> &vec, Ts
&&...values) {
  return vec.emplace_back(std::forward<Ts>(values)...);
}

void f(std::vector<int> &vec) {
  int_vec_emplace_back_wrapper(vec, nullptr);
}


GCC's diagnostic includes a mention the erroneous line 9 but Clang's diagnostic
doesn't:


In file included from a.cpp:1:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/vector:61:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/allocator.h:46:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/c++allocator.h:33:
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/ext/new_allocator.h:136:23:
error: cannot initialize a new value of type 'int' with an rvalue of type
'nullptr_t'
        { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
                             ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/alloc_traits.h:475:8:
note: in instantiation of function template specialization
'__gnu_cxx::new_allocator<int>::construct<int, nullptr_t>' requested here
        { __a.construct(__p, std::forward<_Args>(__args)...); }
              ^
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/vector.tcc:103:21:
note: in instantiation of function template specialization
'std::allocator_traits<std::allocator<int> >::construct<int, nullptr_t>'
requested here
            _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
                           ^
a.cpp:5:14: note: in instantiation of function template specialization
'std::vector<int, std::allocator<int> >::emplace_back<nullptr_t>' requested
here
  return vec.emplace_back(std::forward<Ts>(values)...);
             ^
1 error generated.


(Removing int_vec_emplace_back_wrapper()'s variadicity doesn't improve the
diagnostic but giving it an explicit void return type does)

<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Diagnostic doesn't include interesting template instantiation location"
   href="show_bug.cgi?id=20452">https://bugs.llvm.org/show_bug.cgi?id=20452</a> touches similar issues but I don't
believe it subsumes this.</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>