1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: 32-bit-pointer 10 // REQUIRES: large_tests 11 12 // Test that tellp() does not break the stringstream after INT_MAX, due to use 13 // of pbump() that accept int. 14 15 #include <cassert> 16 #include <climits> 17 #include <sstream> 18 #include <string> 19 20 int main(int, char**) { 21 std::stringstream ss; 22 std::string payload(INT_MAX - 1, '\0'); 23 24 ss.write(payload.data(), payload.size()); 25 assert(ss.tellp() == INT_MAX - 1); 26 27 ss.write("a", 1); 28 assert(ss.tellp() == INT_MAX); 29 30 ss.write("b", 1); 31 assert(ss.tellp() == INT_MAX + 1ULL); 32 // it fails only after previous tellp() corrupts the internal field with int 33 // overflow 34 assert(ss.tellp() == INT_MAX + 1ULL); 35 36 return 0; 37 } 38