Hi, I have this simple program: #include <regex> int main() { std::regex re; re.assign(std::regex("foo")); // SIGILL return 0; } It runs smoothly if compiled with g++ but raises "illegal instruction" when compiled with clang++: g++ -std=c++11 -O0 -g -o test-g++ test.cpp clang++ -std=c++11 -O0 -g -o test-clang++ test.cpp ptomulik at barakus:$ ./test-g++ ptomulik at barakus:$ ./test-clang++ Illegal instruction Note that the following assignment still works: re.assign(static_cast<std::regex const&>(std::regex("foo"))); I'm working on Debian 8.0, my clang version is: ptomulik at barakus:$ clang++ --version Debian clang version 3.5.0-9 (tags/RELEASE_350/final) (based on LLVM 3.5.0) Target: x86_64-pc-linux-gnu Thread model: posix Where should I report the bug? Regards! -- Pawel Tomulik
Hi Paweł> Where should I report the bug?LLVM appears to be calling this function from libstdc++'s regex.h (4.9.2 in my case): basic_regex& assign(basic_regex&& __rhs) { _M_flags = __rhs._M_flags; _M_original_str = std::move(__rhs._M_original_str); __rhs._M_automaton.reset(); this->imbue(__rhs.getloc()); } This is declared to return a basic_regex but doesn't, which LLVM ends up emitting an undefined instruction trap for. This is valid because the function has undefined behaviour. So I say libstdc++, unless they've already fixed it. Cheers. Tim.
W dniu 13.02.2015 o 05:57, Tim Northover pisze:> Hi Paweł > >> Where should I report the bug? > LLVM appears to be calling this function from libstdc++'s regex.h > (4.9.2 in my case): > > basic_regex& assign(basic_regex&& __rhs) > { > _M_flags = __rhs._M_flags; > _M_original_str = std::move(__rhs._M_original_str); > __rhs._M_automaton.reset(); > this->imbue(__rhs.getloc()); > } > > This is declared to return a basic_regex but doesn't, which LLVM ends > up emitting an undefined instruction trap for. This is valid because > the function has undefined behaviour. > > So I say libstdc++, unless they've already fixed it. > > Cheers. > > Tim.Thanks, according to https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00854.html it's fixed in gcc-4.9.3. -- Paweł Tomulik, tel. (22) 234 7925 Instytut Techniki Lotniczej i Mechaniki Stosowanej Politechnika Warszawska