[libcxx] r325147 - Add a catch for std::length_error for the case where the string can't handle 2GB. (like say 32-bit big-endian)

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 10:05:25 PST 2018


Author: marshall
Date: Wed Feb 14 10:05:25 2018
New Revision: 325147

URL: http://llvm.org/viewvc/llvm-project?rev=325147&view=rev
Log:
Add a catch for std::length_error for the case where the string can't handle 2GB. (like say 32-bit big-endian)


Modified:
    libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp

Modified: libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp?rev=325147&r1=325146&r2=325147&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp Wed Feb 14 10:05:25 2018
@@ -32,12 +32,13 @@ int main()
 #ifndef TEST_HAS_NO_EXCEPTIONS
     try {
 #endif
-    	std::string str(2147483648, 'a');
-		SB sb;
-		sb.str(str);
-		assert(sb.pubpbase() <= sb.pubpptr());
+        std::string str(2147483648, 'a');
+        SB sb;
+        sb.str(str);
+        assert(sb.pubpbase() <= sb.pubpptr());
 #ifndef TEST_HAS_NO_EXCEPTIONS
-	}
-	catch (const std::bad_alloc &) {}
+    }
+    catch (const std::length_error &) {} // maybe the string can't take 2GB
+    catch (const std::bad_alloc    &) {} // maybe we don't have enough RAM
 #endif
 }




More information about the cfe-commits mailing list