<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 - Unused function false positive on SFINAE disabled function"
href="https://bugs.llvm.org/show_bug.cgi?id=44609">44609</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Unused function false positive on SFINAE disabled function
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rick_water@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>In the code below, Clang flags a function as unused and produces a warning,
even though the function is disabled through SFINAE. It was also tested on GCC
and MSVC which don't produce any warnings, so I think this behaviour is
incorrect. I've tested it as far back as I could with compiler explorer, and it
is happening from at least version 3.3 all the way up to the latest version.
Code:
=====================
#include <cstddef>
#include <iterator>
#include <type_traits>
template <typename T, typename Tag>
class pointer_iterator
{
public:
using iterator_catagory = std::random_access_iterator_tag;
using value_type = T;
using difference_type = std::ptrdiff_t;
using pointer = T*;
using reference = T&;
template <typename _ = int, typename
std::enable_if<!std::is_same<value_type, const value_type>::value, _>::type =
0>
operator pointer_iterator<const value_type, Tag>()
{
return pointer_iterator<const value_type, Tag>(_value);
}
private:
pointer _value = nullptr;
};
int main()
{
pointer_iterator<const int, void> it;
}
=====================
Output:
=====================
Warning:
warning: conversion function converting 'pointer_iterator<const int, void>' to
itself will never be used
operator pointer_iterator<const value_type, Tag>()
^
note: in instantiation of template class 'pointer_iterator<const int, void>'
requested here
pointer_iterator<const int, void> it;
^
====================</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>