[Bug c++/95686] New: undefined reference to static local variable within inline function
leni536 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 15 17:51:22 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95686
Bug ID: 95686
Summary: undefined reference to static local variable within
inline function
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: leni536 at gmail dot com
Target Milestone: ---
The following code produces an "undefined reference to `foo()::i'" linker
error:
template <const int* ptr>
struct S {
static constexpr const int* value = ptr;
};
inline
auto foo() {
static const int i = 0;
return S<&i>{};
}
#include <iostream>
int main() {
std::cout << decltype(foo())::value;
}
More information about the Gcc-bugs
mailing list