http://llvm.org/bugs/show_bug.cgi?id=17771

            Bug ID: 17771
           Summary: Unexpected length_error on string::resize(max_size(),
                    ..)
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

This code exit with status 1(length_error):

#include <string>
#include <stdexcept>

int main() {
  try {
    std::string s;
    s.resize(s.max_size(), 'x');
    return 0;
  }
  catch (std::length_error& exc) {
    return 1;
  }
  catch (std::bad_alloc& exc) {
    return 2;
  }
}

expected 0(OK) or 2(bad_alloc).

C++ Standard 2011, 21.4.4 basic_string capacity [string.capacity]:
void resize(size_type n, charT c);
7. Throws: length_error if n > max_size().

Changing '-libstd=libc++' to '-stdlib=libstdc++' help, return status is 2
(bad_alloc).

libcxx version(git): 76a8670ce4404429a36ea8672590da79172528c8

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to