Public bug reported:

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::regex_match(str, match, re);

  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::cpp_regex_traits<char>::transform[abi:cxx11](char const*, char const*) 
const':
boost-clang-bug.cpp:(.text._ZNK5boost16cpp_regex_traitsIcE9transformB5cxx11EPKcS3_[_ZNK5boost16cpp_regex_traitsIcE9transformB5cxx11EPKcS3_]+0x23):
 undefined reference to 
`boost::re_detail::cpp_regex_traits_implementation<char>::transform[abi:cxx11](char
 const*, char const*) const'
/tmp/boost-clang-bug-64dd61.o: In function 
`boost::cpp_regex_traits<char>::transform_primary[abi:cxx11](char const*, char 
const*) const':
boost-clang-bug.cpp:(.text._ZNK5boost16cpp_regex_traitsIcE17transform_primaryB5cxx11EPKcS3_[_ZNK5boost16cpp_regex_traitsIcE17transform_primaryB5cxx11EPKcS3_]+0x23):
 undefined reference to 
`boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary[abi:cxx11](char
 const*, char const*) const'
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/images/hvm-ssd
/ubuntu-xenial-16.04-amd64-server-20170113 (ami-7c803d1c)) updating and
installing these:

$ 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://us-west-2.ec2.archive.ubuntu.com/ubuntu 
xenial-updates/universe amd64 Packages
        100 /var/lib/dpkg/status
     1:3.8-2ubuntu1 500
        500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu xenial/universe 
amd64 Packages

** Affects: llvm-toolchain-3.8 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to llvm-toolchain-3.8 in Ubuntu.
https://bugs.launchpad.net/bugs/1664321

Title:
  clang + boost regex + xenial = linker error

Status in llvm-toolchain-3.8 package in Ubuntu:
  New

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::regex_match(str, match, re);

    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::cpp_regex_traits<char>::transform[abi:cxx11](char const*, char const*) 
const':
  
boost-clang-bug.cpp:(.text._ZNK5boost16cpp_regex_traitsIcE9transformB5cxx11EPKcS3_[_ZNK5boost16cpp_regex_traitsIcE9transformB5cxx11EPKcS3_]+0x23):
 undefined reference to 
`boost::re_detail::cpp_regex_traits_implementation<char>::transform[abi:cxx11](char
 const*, char const*) const'
  /tmp/boost-clang-bug-64dd61.o: In function 
`boost::cpp_regex_traits<char>::transform_primary[abi:cxx11](char const*, char 
const*) const':
  
boost-clang-bug.cpp:(.text._ZNK5boost16cpp_regex_traitsIcE17transform_primaryB5cxx11EPKcS3_[_ZNK5boost16cpp_regex_traitsIcE17transform_primaryB5cxx11EPKcS3_]+0x23):
 undefined reference to 
`boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary[abi:cxx11](char
 const*, char const*) const'
  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/images/hvm-ssd
  /ubuntu-xenial-16.04-amd64-server-20170113 (ami-7c803d1c)) updating
  and installing these:

  $ 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://us-west-2.ec2.archive.ubuntu.com/ubuntu 
xenial-updates/universe amd64 Packages
          100 /var/lib/dpkg/status
       1:3.8-2ubuntu1 500
          500 http://us-west-2.ec2.archive.ubuntu.com/ubuntu xenial/universe 
amd64 Packages

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/llvm-toolchain-3.8/+bug/1664321/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : desktop-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to