https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85098
Bug ID: 85098 Summary: undefined reference to std::regex::extended Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: john.salmon at deshaw dot com Target Milestone: --- When I compile with -std=c++11 or -std=c++14 and with -O0, I get this undefined reference. With -std=c++17, there's no problem. With -O1 and higher, there's no problem. Note that with -std=c++14 and 17, 'mu' is just plain-old std::make_unique. To demonstrate the problem with -std=c++11, I had to define "my own" make_unique. drdws0134$ cat foo.cpp #include <memory> #include <regex> #if __cplusplus >= 201402L #define mu std::make_unique #else template <typename T, typename ... Args> std::unique_ptr<T> mu(Args&& ... args){ return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } #endif auto re = mu<std::regex>("hello", std::regex::extended); int main(int, char **){ return 0; } drdws0134$ drdws0134$ garden with -m gcc/7.3.0-01c7/bin g++ -std=c++11 -O0 foo.cpp /tmp/ccJeBOid.o: In function `__static_initialization_and_destruction_0(int, int)': foo.cpp:(.text+0xd9): undefined reference to `std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::extended' collect2: error: ld returned 1 exit status drdws0134$ garden with -m gcc/7.3.0-01c7/bin g++ -std=c++14 -O0 foo.cpp /tmp/cc2NKXJx.o: In function `__static_initialization_and_destruction_0(int, int)': foo.cpp:(.text+0xd9): undefined reference to `std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::extended' collect2: error: ld returned 1 exit status drdws0134$ garden with -m gcc/7.3.0-01c7/bin g++ -std=c++17 -O0 foo.cpp drdws0134$