Public bug reported:

Tried compiling a very simple c++ program:

#include <string>
#include <iostream>

int main()
{
    try
    {
        std::string x;
        char z = x.at(2);
        std::cout << z << std::endl;
    }
    catch (...)
    {
    }

    return 0;
}

clang++ -stdlib=libc++ -Wall -Werror ./temp.cpp -o output

When run, it asserts:

./output
output: ../../libcxx/include/string:1175: void 
std::__1::__basic_string_common<true>::__throw_out_of_range() const: Assertion 
`!"basic_string out_of_range"' failed.
[1]    27852 abort (core dumped)  ./output

Expected behaviour is no assert, and program just returns. (This is the
behaviour if -stdlib=libc++ is omitted).

I believe this is similar to
https://github.com/kripken/emscripten/issues/4053, ie. libcxxabi has
compiled strings without exceptions, and that is the version being
linked.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: libc++-dev 3.7.0-1 [modified: usr/include/c++/v1/string]
ProcVersionSignature: Ubuntu 4.4.0-22.40-generic 4.4.8
Uname: Linux 4.4.0-22-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
Date: Fri May 27 10:50:06 2016
Dependencies:
 gcc-6-base 6.0.1-0ubuntu1
 libc++-helpers 3.7.0-1
 libc++1 3.7.0-1
 libc6 2.23-0ubuntu3
 libgcc1 1:6.0.1-0ubuntu1
InstallationDate: Installed on 2015-05-06 (386 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Release amd64 (20150422)
SourcePackage: libc++
UpgradeStatus: Upgraded to xenial on 2016-05-26 (0 days ago)

** Affects: libc++ (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/1586215

Title:
  libc++ does not throw exceptions as expected

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libc++/+bug/1586215/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to