[LLVMbugs] [Bug 19713] New: -Wunused-function complains (spammily) about static constexpr functions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun May 11 13:31:42 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19713

            Bug ID: 19713
           Summary: -Wunused-function complains (spammily) about static
                    constexpr functions
           Product: clang
           Version: 3.4
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

constexpr functions are inline by definition:

    (ยง7.1.5/2): "constexpr functions and constexpr constructors are implicitly
inline (7.1.2)."

However, when you feed Clang 3.4 the following translation unit, you get
-Wunused-function errors:

cat >test.h <<EOF
static inline int isI() { return 1; }
static constexpr int isC() { return 1; }
static inline constexpr int isIandC() { return 1; }
EOF
cat >test.cc <<EOF
#include "test.h"
int main() {}
EOF
clang++ test.cc -std=c++11 -Wunused-function

    In file included from test.cc:1:
    ./test.h:2:22: warning: unused function 'isC' [-Wunused-function]
    static constexpr int isC() { return 1; }
                         ^
    1 warning generated.

The -Wunused-function diagnostic should be suppressed for "static constexpr
[inline]" functions the same way it's suppressed for "static inline" functions.
Otherwise, any C++11 project that includes third-party header files has to pass
-Wno-unused-function, and that's annoying.

-- 
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/20140511/21c2b6b8/attachment.html>


More information about the llvm-bugs mailing list