[llvm-bugs] [Bug 49684] New: Bug with const and partial template spepcialization in C++17
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 22 10:12:33 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49684
Bug ID: 49684
Summary: Bug with const and partial template spepcialization in
C++17
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: eldlistmailingz at tropicsoft.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210322/e434e244/attachment.html>
More information about the llvm-bugs
mailing list