When are expressions contained within a function labeled in a string considered “potentially evaluated”?
a.cpp
template <typename T>
const T& foo(const T& arg) { return arg; }
inline void dead() {
int x(21);
x = foo(x);
}
b.cpp
#include <iostream>
template <typename T> const T& foo(const T&);
int main(int argc, char *argv[]) {
std::cout << foo(12) << std::endl;
}
If the expressions are considered "potentially evaluated" as soon as the built-in function is defined, then the template should be created, and I expect it $(CCC) -c a.cpp; $(CCC) -c b.cpp; $(CCC) a.o b.o -o binto communicate successfully. If instead the expressions inside the function declared inline become only "potentially evaluated" when such a function itself is used as odr, then I expect it $(CCC) -c a.cpp; $(CCC) -c b.cpp; $(CCC) a.o b.o -o binto fail at the link stage.
So far I have tested xl C ++ 12 (which successfully connect) and various versions of gcc + clang 3.5 (all of which are unrelated).
? ?