https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101800
Bug ID: 101800 Summary: mingw-64 link error with constexpr static variable definition Product: gcc Version: 10.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: koncek.marian at gmail dot com Target Milestone: --- Version: x86_64-w64-mingw32-g++ (GCC) 10.3.1 20210422 (Fedora MinGW 10.3.1-1.fc34) Using 3 source files: //////////////////////////////////// <test.hpp> #pragma once struct S { const static int value; }; //////////////////////////////////// <test.cpp> #include "test.hpp" constexpr int S::value = 0; //////////////////////////////////// <main.cpp> #include "test.hpp" int main() { return S::value; } //////////////////////////////////// Compile with: $ x86_64-w64-mingw32-g++ -std=c++2a -c test.cpp && x86_64-w64-mingw32-g++ -std=c++2a test.o main.cpp Results in: /usr/lib/gcc/x86_64-w64-mingw32/10.3.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/ccANpWMi.o:main.cpp:(.rdata$.refptr._ZN1S5valueE[.refptr._ZN1S5valueE]+0x0): undefined reference to `S::value' collect2: error: ld returned 1 exit status Whereas plain g++ is able to link the files in the executable. Changing the `constexpr` definition to `const` makes mingw link the files successfully.