true/false bug
Brad Garcia
bgarcia@laurelnetworks.com
Thu Apr 20 05:49:00 GMT 2000
Ok, fess up! Who did this? ;^)
Note the ordering of the arguments.
bits/locale_facets.h:
...
void
_M_init_boolnames(const string_type& __t, const string_type& __f)
{
_M_truename = __t;
_M_falsename = __f;
}
...
template<>
numpunct<char>::numpunct(size_t __refs): _Numpunct<char>(__refs)
{
_M_init('.', ',', "");
_M_init_boolnames("false", "true");
}
#ifdef _GLIBCPP_USE_WCHAR_T
template<>
numpunct<wchar_t>::numpunct(size_t __refs): _Numpunct<wchar_t>(__refs)
{
_M_init(L'.', L',', "");
_M_init_boolnames(L"false", L"true");
}
#endif
...
Here's a test case that shows the bug.
Notice also that iostream (or one of the files that it is
including) should itself be including sys/types.h, since it uses some of
the types defined there.
--------------------------------------------------------------------------
#include <sys/types.h> // why?
#include <iostream>
int
main()
{
std::locale loc("");
(void) locale::global(loc);
loc = locale::locale();
cout.imbue(loc);
cout << "true == " << true << endl;
cout << "false == " << false << endl;
std::ios_base::fmtflags ff = cout.flags(std::ios_base::boolalpha);
cout << "true == " << true << endl;
cout << "false == " << false << endl;
cout.flags(ff);
return 0;
}
Brad Garcia
More information about the Libstdc++
mailing list