<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 - Bug with const and partial template spepcialization in C++17"
   href="https://bugs.llvm.org/show_bug.cgi?id=49684">49684</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bug with const and partial template spepcialization in C++17
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++17
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>eldlistmailingz@tropicsoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The code:

#include <iostream>
#include <cstddef>
#include <type_traits>

template <class T,T (*g)(),bool (*s)(T),class NP = std::nullptr_t,class dummy =
void>  struct pfun;

template <class T,T (*g)(),bool (*s)(T)>
struct pfun<T,g,s,std::nullptr_t,typename std::enable_if<g != nullptr &&
(std::is_const<T>::value || s == nullptr)>::type>
  {
  pfun() {std::cout << "class pfun<T,g,s,std::nullptr_t,typename
std::enable_if<g != nullptr && (std::is_const<T>::value || s ==
nullptr)>::type>\n";} 
  };

char const gl_r_const_ch('c');
char const gl_fun_r_read_const_ch()  { return gl_r_const_ch; }
pfun<char const,&gl_fun_r_read_const_ch,nullptr> pf_read_const_ch;

// char gl_r_ch('c');
// char gl_fun_r_read_ch()  { return gl_r_ch; }
// pfun<char,&gl_fun_r_read_ch,nullptr> pf_read_ch;

int main() { return 0; }

Compiled with clang 11.0 the result is:

"test_pmf.cpp:15:50: error: implicit instantiation of undefined template
'pfun<const char, &gl_fun_r_read_const_ch, nullptr, nullptr_t, void>'
pfun<char const,&gl_fun_r_read_const_ch,nullptr> pf_read_const_ch;
                                                 ^
test_pmf.cpp:5:95: note: template is declared here
template <class T,T (*g)(),bool (*s)(T),class NP = std::nullptr_t,class dummy =
void>  struct pfun;"

If you uncomment the three commented lines and comment the three lines above it
( disregarding the space line ), the code compiles with no errors. Furthermore
if you compile in C++14 mode the code as shown there are no errors, and if you
compile with gcc-10.2 in C++14 or C++17 mode there are no errors. Using a 'char
const' rather than just a 'char' should not result in the code not working in
C++17.</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>