[LLVMbugs] [Bug 16329] New: undefined-inline warning when constexpr is used

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 14 04:01:47 PDT 2013


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

            Bug ID: 16329
           Summary: undefined-inline warning when constexpr is used
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: steveire at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

stephen at hal:/tmp$ clang++ --version
Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM
3.2)
Target: x86_64-pc-linux-gnu
Thread model: posix

stephen at hal:/tmp$ clang++ -std=c++11 -DUSE_CONSTEXPR -c test.cpp 

stephen at hal:/tmp$ clang++ -std=c++11 -c test.cpp 

stephen at hal:/tmp$ ~/dev/build/qtbase/llvm/bin/clang++ --version
clang version 3.4 
Target: x86_64-unknown-linux-gnu
Thread model: posix

stephen at hal:/tmp$ ~/dev/build/qtbase/llvm/bin/clang++ -std=c++11
-DUSE_CONSTEXPR -c test.cpp
test.cpp:9:20: warning: inline function 'typeId<A>' is not defined
[-Wundefined-inline]
DECL_CONSTEXPR int typeId();
                   ^
test.cpp:19:15: note: used here
        (void)typeId<A>();
              ^
1 warning generated.

stephen at hal:/tmp$ ~/dev/build/qtbase/llvm/bin/clang++ -std=c++11 -c test.cpp

stephen at hal:/tmp$ g++ --version
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


stephen at hal:/tmp$ g++ -std=c++11 -DUSE_CONSTEXPR -c test.cpp

stephen at hal:/tmp$ g++ -std=c++11 -c test.cpp

stephen at hal:/tmp$ cat test.cpp 

#ifdef USE_CONSTEXPR
#define DECL_CONSTEXPR constexpr
#else
#define DECL_CONSTEXPR
#endif

template <typename T>
DECL_CONSTEXPR int typeId();

struct A {};

template<typename T>
struct Template
{
    static void registerType(T t)
    {
        t.does_not_compile;
        (void)typeId<A>();
    }
};

template <typename T>
DECL_CONSTEXPR int typeId()
{
    return 0;
}

void avoidWarning()
{
//     (void)typeId<A>();
}


The warning is not emitted if the contents of avoidWarning are uncommented.

-- 
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/20130614/238100d0/attachment.html>


More information about the llvm-bugs mailing list