public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: libstdc++/5133: Problems with toupper Date: Sun, 16 Dec 2001 15:46:00 -0000 [thread overview] Message-ID: <20011216234600.27702.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/5133; it has been noted by GNATS. From: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de> To: paolo@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, paolo@gcc.gnu.org, schmid@snake.iap.physik.tu-darmstadt.de, gcc-gnats@gcc.gnu.org Cc: Subject: Re: libstdc++/5133: Problems with toupper Date: Mon, 17 Dec 2001 00:39:53 +0100 (CET) On 16 Dec 2001 paolo@gcc.gnu.org wrote: > Synopsis: Problems with toupper > > Responsible-Changed-From-To: unassigned->paolo > Responsible-Changed-By: paolo > Responsible-Changed-When: Sun Dec 16 13:53:55 2001 > Responsible-Changed-Why: > Taking care of this. > State-Changed-From-To: open->feedback > State-Changed-By: paolo > State-Changed-When: Sun Dec 16 13:53:55 2001 > State-Changed-Why: > Hi Peter, > > in Josuttis, pp. 499 and 718 I find an explanation of what > is happening with your testcase. In a nutshell, tolower and > toupper are old C functions (you may use them through > cctype) whereas std::toupper(c, loc) (and the corresponding > tolower) are global functions of the C++ locales. > Therefore, your testcase should be changed to: > > #include <string> > #include <iostream> > #include <algorithm> > #include <cctype> > > int main() > { > std::string s("Hallo"); > //std::transform (s.begin(), s.end(), s.begin(), std::tolower); > //std::transform (s.begin(), s.end(), s.begin(), ::tolower); > std::transform (s.begin(), s.end(), s.begin(), tolower); > std::cout << "lowered: " << s << std::endl; > } > > which indeed compiles and runs fine. > > Ok? > > Cheers, > Paolo. > > > > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5133 > It is IMHO not ok. If you consider the following source tl.C, a stripped down version from string/iter1.C from Josuttis, cf. pages number 497--499. Also cf. page number 720. I believe that this source code is legal and according to Josuttis the <c*> headers inject the corresponding <*.h> functions into the std namespace. Therefore, I have no idea why this code, the call to std::tolower is rejected. Additionally, why does the code compile if the iostream header is removed? Peter Schmid tl.C #include <string> #include <iostream> // does work, when this line is removed #include <algorithm> #include <cctype> using namespace std; int main() { string s("Hallo"); transform (s.begin(), s.end(), s.begin(), tolower); transform (s.begin(), s.end(), s.begin(), ::tolower); } g++ -o tl tl.C -W -Wall tl.C: In function `int main()': tl.C:11: no matching function for call to `transform( std::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unknown type>)'
next reply other threads:[~2001-12-16 23:46 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-12-16 15:46 Peter Schmid [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-11-22 14:46 Pete Ratzlaff 2002-11-22 13:48 Martin Sebor 2002-11-22 5:43 Phil Edwards 2002-11-22 5:41 Pete Ratzlaff 2002-11-22 5:11 Pete Ratzlaff 2002-10-31 16:08 paolo 2002-06-27 23:14 Christopher Currie 2001-12-17 8:06 Philip Martin 2001-12-16 17:46 Martin Sebor 2001-12-16 13:53 paolo 2001-12-16 13:16 Peter Schmid
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20011216234600.27702.qmail@sources.redhat.com \ --to=schmid@snake.iap.physik.tu-darmstadt.de \ --cc=gcc-prs@gcc.gnu.org \ --cc=paolo@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).