https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118693
Bug ID: 118693 Summary: istream& getline (istream& is, string& str, char delim) does not return with long input Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: alban...@baker-research.com Target Milestone: --- Created attachment 60314 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60314&action=edit Test program, .s, .ii files, compiler command and output, sample ouptut. Hi, In c++, the function istream& getline (istream& is, string& str, char delim) doesn't return when" 1) delim is '>', and 2) The input to stream "is" consists of 'A' repeated 4926 times followed by '>'. In this case, the size of str is usually around 4096 instead of the expected value of 4926. However, getline() does return if either: 1) The input consists of 'A' repeated 2000 times followed by '>'. In this case, the size of str is 2000, as expected. 2) The input consists of 'A' repeated 4926 followed by ">\n>". In this case, the size of str is usually around 4096 instead of the expected value of 4926. I've attached testDecludeFilter.tar.gz that contains: 1) The test program testGetline.cpp. Run the test by running testGetline, and providing the input by cutting the specified number of 'A' characters from a file, and pasting. 2) Compiler command. 3) Compiler output. 4) .s and .ii files. 5) Input and output with 4926 'A' characters. For me a satisfactory solution would be to change the documentation of getline() to state that the input must not exceed a value before the delim character. However, that might not satisfy everyone. Thanks, Alban