Public bug reported: Calling regex_replace with -O3 will crash no matter the input. This seems to have started occurring after an apt-get upgrade, but I cannot say for sure exactly what package update might have caused it. We were able to run similar code in previous builds of 16.04.
If you compile without -O3, it runs. clang++ --std=c++14 -O3 test.cpp test.cpp: #include <regex> #include <string> #include <iostream> int main() { const std::string& output = regex_replace("", std::regex(""), ""); std::cout << output << "\n"; return 0; } Description: Ubuntu 16.04.3 LTS Release: 16.04 clang: Installed: 1:3.8-33ubuntu3.1 Candidate: 1:3.8-33ubuntu3.1 Version table: *** 1:3.8-33ubuntu3.1 500 500 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages 100 /var/lib/dpkg/status 1:3.8-33ubuntu3 500 500 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages ProblemType: Bug DistroRelease: Ubuntu 16.04 Package: clang 1:3.8-33ubuntu3.1 ProcVersionSignature: Ubuntu 4.13.0-32.35~16.04.1-generic 4.13.13 Uname: Linux 4.13.0-32-generic x86_64 NonfreeKernelModules: nvidia_uvm nvidia_drm nvidia_modeset nvidia ApportVersion: 2.20.1-0ubuntu2.15 Architecture: amd64 CurrentDesktop: Unity Date: Thu Feb 8 20:23:48 2018 InstallationDate: Installed on 2017-08-17 (175 days ago) InstallationMedia: Ubuntu 16.04.3 LTS "Xenial Xerus" - Release amd64 (20170801) ProcEnviron: LANGUAGE=en_US PATH=(custom, no user) XDG_RUNTIME_DIR=<set> LANG=en_US.UTF-8 SHELL=/bin/bash SourcePackage: llvm-defaults UpgradeStatus: No upgrade log present (probably fresh install) ** Affects: llvm-defaults (Ubuntu) Importance: Undecided Status: New ** Tags: amd64 apport-bug xenial -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1748344 Title: clang++ regex_replace always segfaults with -O3 To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1748344/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs