llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

boolalpha seems to ignore output width

Open edfvogel opened this issue 5 years ago • 3 comments

Bugzilla Link 52301
Resolution DUPLICATE
Resolved on Oct 27, 2021 06:12
Version 11.0
OS All
CC @mclow

Extended Description

It seems that the boolalpha fmtflag ignores any specified width.

Here's a cut/paste from a cut/paste from a cygwin session:

$ cat t.cpp

#include #include #include using namespace std; int main(int, char *[]) { stringbuf sbuf; ostream ostr(&sbuf); ostr << boolalpha << setw(7) << (bool)false; string s = sbuf.str(); cout << "'" << sbuf.str() << "'"; }

VogelEd@XLB3502Q4E ~/temp $ clang++ -o a.out t.cpp

VogelEd@XLB3502Q4E ~/temp $ ./a.out ' false' VogelEd@XLB3502Q4E ~/temp $ clang++ -o a.out -stdlib=libc++ t.cpp

VogelEd@XLB3502Q4E ~/temp $ ./a.out 'false' VogelEd@XLB3502Q4E ~/temp

edfvogel avatar Oct 25 '21 22:10 edfvogel

*** This bug has been marked as a duplicate of bug llvm/llvm-project#33027 ***

mclow avatar Oct 27 '21 13:10 mclow

Thanks so much for the quick response!

No hurry on this at all. Just pointing out an incompatibility between libc++ and other popular libraries. It really does not matter who is "right", it's simply something a user may encounter when they port from g++ or Visual Studio to libc++.

Take care,

Ed

edfvogel avatar Oct 26 '21 14:10 edfvogel

I seem to recall that this is the way it's specified. All the other manipulators say "apply width and filler", but this one doesn't.

I'm at CppCon this week, so I'm doing this from memory. I'll try to dig up references next week.

mclow avatar Oct 26 '21 14:10 mclow