public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Martin Sebor <sebor@roguewave.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: libstdc++/5133: Problems with toupper Date: Sun, 16 Dec 2001 17:46:00 -0000 [thread overview] Message-ID: <20011217014601.26376.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/5133; it has been noted by GNATS. From: Martin Sebor <sebor@roguewave.com> To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: libstdc++/5133: Problems with toupper Date: Sun, 16 Dec 2001 18:54:22 -0700 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5133 None of the programs in this PR is well-formed for at least two reasons: 1. The first two refer to ::tolower or tolower without either first #including <ctype.h>, or #including <cctype> *and* bringing std::tolower into the global namespace via a using declaration or directive. 2. The four-argument overload of std::transform() is a template that expects a unary function [object] as its last argument, i.e., a class type that defines operator() or a one argument function with extern "C++" linkage. None of the two overloads of std::tolower is likely to be such a function (the unary version that's intended to be used is likely to have an extern "C" linkage since it's a C library function). In fact, they are known to be extern "C" in glibc on Linux, the reported platform. Paolo's suggested change suffers from a variant of 1, except that it doesn't qualify the name at all. It has the same problem as 2. IMO, there are two reasons why this example compiles with gcc: one of the headers inadvertently introduces the unary function tolower into the global namespace, and the compiler fails to diagnose the incompatibility of an extern "C" function with a pointer to an extern "C++" function. The short story is that you cannot portably pass a function declared in one of the C++ C library headers (such as <cctype> or the deprecated <ctype.h>) as a template argument to a function template, since the linkage of the latter requires that that the argument have C++ linkage which is not guaranteed by the C++ Standard. For this reason, the example is Jossutis' book is unportable and ill-formed on all platforms I'm familiar with. Regards Martin
next reply other threads:[~2001-12-17 1:46 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-12-16 17:46 Martin Sebor [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 15:46 Peter Schmid 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=20011217014601.26376.qmail@sources.redhat.com \ --to=sebor@roguewave.com \ --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).