libc++ does not throw exceptions as expected

Bug #1586215 reported by Andrew King
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libc++ (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

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)

Revision history for this message
Andrew King (eurokang) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libc++ (Ubuntu):
status: New → Confirmed
Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

No longer happening, closing.

Changed in libc++ (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.