[Bug c++/92786] New: [c++11] static constexpr member link error
xavierb at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Dec 4 06:14:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92786
Bug ID: 92786
Summary: [c++11] static constexpr member link error
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: xavierb at gmail dot com
Target Milestone: ---
hi,
this code doesn't link:
---
struct STest {
static int GetVal(int x) {return vals[x];}
static constexpr int vals[] = { 1,2,3,4,4,4,4 };
};
int main()
{
return STest::GetVal(1);
}
---
/usr/bin/ld: /tmp/ccqFvLiy.o: in function `STest::GetVal(int)':
bug.cpp:(.text._ZN5STest6GetValEi[_ZN5STest6GetValEi]+0x17): undefined
reference to `STest::vals'
collect2: error: ld returned 1 exit status
(seems to work fine with
clang >= 9 (but not with version <=8),
msvc and icc )
More information about the Gcc-bugs
mailing list