[llvm-bugs] [Bug 44609] New: Unused function false positive on SFINAE disabled function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 21 11:40:20 PST 2020


            Bug ID: 44609
           Summary: Unused function false positive on SFINAE disabled
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rick_water at hotmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

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.

#include <cstddef>
#include <iterator>
#include <type_traits>

template <typename T, typename Tag>
class pointer_iterator
        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 =
        operator pointer_iterator<const value_type, Tag>()
                return pointer_iterator<const value_type, Tag>(_value);

        pointer _value = nullptr;

int main()
        pointer_iterator<const int, void> it;


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;

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/20200121/8f0d310a/attachment.html>

More information about the llvm-bugs mailing list