https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69944
Bug ID: 69944 Summary: ctype::widen issue, use self-define do_widen, get unexpected result. Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcc Assignee: unassigned at gcc dot gnu.org Reporter: derrick at ca dot ibm.com Target Milestone: --- I compile the following code under gcc5.2. $g++ -std=c++11 test.cpp -o test #include <locale> #include <codecvt> #include <stdio.h> typedef char Mychar; #include <cctype> int cnt_; struct Mycty_ : public std::ctype<Mychar> { protected: Mychar do_widen(char c) const {++cnt_; return (std::tolower(c)); } const char *do_widen(const char *first1, const char *last1, Mychar *first2) const {++cnt_; *first2 = do_tolower(*first1); return (last1); } }; int main(int argc, char *argv[]) { Mycty_ fac; cnt_ = 0; if (fac.widen('A')=='a') printf ("111\n"); if(fac.widen('0')=='0') printf("222\n"); return 0; } I expected it should print 111 and 222. But only 111 is print. If comment "if (fac.widen('A')=='a')", then 222 can be print. I suspect if the lib has issue.