When I attempt compiling the following code I get a linker error: Undefined symbols for architecture x86_64: "Foo()", referenced from: _main in main.o using LLVM 4.2.
This behavior only occurs when the function is marked constexpr. The program compiles and links correctly when the function is marked const. Why does declaring the function constexpr cause a linker error?
(I realize that writing the function this way doesn't give the benefit of compile-time computation; at this point I am curious why the function fails to link.)
main.cpp
#include <iostream>
#include "test.hpp"
int main()
{
    int bar = Foo();
    std::cout << bar << std::endl;
    return 0;
}
test.hpp
constexpr int Foo();
test.cpp
#include "test.hpp"
constexpr int Foo()
{
    return 42;
}
 
     
     
    