You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A constexpr function definiton in a header is ignored if a declaration of the same function (without body) is visible in primary source file.
To Reproduce
Steps to reproduce the behavior:
In foo.h:
constexpr int getConstVal() { return 1; }
In foo.cc:
#include <foo.h>
constexpr int getConstVal();
constexpr int v = getConstVal();
template <int V> struct Foo;
template <> struct Foo<1> {
constexpr static int val = 55;
};
int x = Foo<v>::val;
The final line in foo.cc will be highlighted as an error ("symbol 'val' could not be resolved"). This is due to a failure to correctly resolve v as the constant 1 via the call to getConstVal() (which returns 1).
If the definition is moved from the header to the top of foo.cc (or anywhere else in foo.cc) the error goes away.
Expected behavior
No error should be marked. Whether the definition is in a header or in the main source file should make no difference.
Screenshots
See source samples above.
Version Information (please complete the following information):