Skip to content

getline broken, reads an extra line #11189

@llvmbot

Description

@llvmbot
Bugzilla Link 10817
Resolution FIXED
Resolved on May 28, 2013 10:25
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @stbergmann

Extended Description

The following trivial program fails to give the intended results with libc++ — instead of reading one line from the terminal, it reads two.

#include
#include

using namespace std;

int main()
{
cout << "What is your name: ";
string name;

getline(cin, name);
cout << "Hello " << name << endl;

return 0;

}

Here it is without libcxx:

% clang++ -o hello hello.cpp
% ./hello
What is your name: Miss Marple
Hello Miss Marple

... and here it is with libcxx:

% clang++ -stdlib=libc++ -o hello hello.cpp
% ./hello
What is your name: Miss Marple
... oh noes, I need to type another line ... you do test this stuff, right?
Hello Miss Marple

Tested with current trunk (138853) and with Xcode 4.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions