[llvm-bugs] [Bug 32046] New: false positive for -Wunused-member-function when in anonymous namespace

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 23 00:34:37 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=32046

            Bug ID: 32046
           Summary: false positive for -Wunused-member-function when in
                    anonymous namespace
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: weiss at wsoptics.de
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Compiling the following code with -Wunused-member-function results in two
warnings.  Removing the anonymous namespace around the definition of class
Iterator makes the warnings go away.

#include <iostream>
#include <iterator>

#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>

namespace {
        class Iterator : public boost::iterator_facade<Iterator, std::size_t
const, boost::bidirectional_traversal_tag>
        {
        public:
                Iterator() : pos_(0) {}
                std::size_t dereference() const { return pos_; }
                bool equal(Iterator const & other) const { return pos_ ==
other.pos_; }
                void increment() { ++pos_; }
                void decrement() { --pos_; }
        private:
                friend class boost::iterator_core_access;
                std::size_t pos_;
        };
}

int main()
{
        Iterator i;

        std::cout << "i = " << *i << '\n';

        return 0;
}

-- 
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/20170223/5d5af77d/attachment.html>


More information about the llvm-bugs mailing list