clang + boost regex + xenial = linker error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
llvm-toolchain-3.8 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
I get a linker error compiling the following with clang++-3.8 optimization level -O1:
#include <boost/regex.hpp>
int main() {
boost::regex re;
std::string str;
boost::smatch match;
boost:
return 0;
}
It works fine with gcc:
$ g++ -O1 -o boost-clang-bug.gcc boost-clang-bug.cpp -lboost_regex
Or with clang -O0:
$ clang++-3.8 -O0 -o boost-clang-bug.o0 boost-clang-bug.cpp -lboost_regex
But not with clang -O1:
$ clang++-3.8 -O1 -o boost-clang-bug.o1 boost-clang-bug.cpp -lboost_regex
/tmp/boost-clang-bug-64dd61.o: In function `boost:
boost-clang-
/tmp/boost-clang-bug-64dd61.o: In function `boost:
boost-clang-
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Instead of giving an error, I would expect clang to successfully compile and link this program.
I'm using a stock install of xenial (on AWS, ubuntu/
$ sudo apt-get update
$ sudo apt-get install clang-3.8 libboost-regex1.58 g++
Here's relevant versioning information:
$ lsb_release -rd
Description: Ubuntu 16.04.1 LTS
Release: 16.04
$ apt-cache policy clang-3.8
clang-3.8:
Installed: 1:3.8-2ubuntu4
Candidate: 1:3.8-2ubuntu4
Version table:
*** 1:3.8-2ubuntu4 500
500 http://
100 /var/lib/
1:3.8-2ubuntu1 500
500 http://
Status changed to 'Confirmed' because the bug affects multiple users.