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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

stephen@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@hal:/tmp$ clang++ -std=c++11 -DUSE_CONSTEXPR -c test.cpp 

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

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

stephen@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@hal:/tmp$ ~/dev/build/qtbase/llvm/bin/clang++ -std=c++11 -c test.cpp

stephen@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@hal:/tmp$ g++ -std=c++11 -DUSE_CONSTEXPR -c test.cpp

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

stephen@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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to