From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26436 invoked by alias); 17 Dec 2001 01:46:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26378 invoked by uid 71); 17 Dec 2001 01:46:01 -0000 Date: Sun, 16 Dec 2001 17:46:00 -0000 Message-ID: <20011217014601.26376.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Martin Sebor Subject: Re: libstdc++/5133: Problems with toupper Reply-To: Martin Sebor X-SW-Source: 2001-12/txt/msg00933.txt.bz2 List-Id: The following reply was made to PR libstdc++/5133; it has been noted by GNATS. From: Martin Sebor 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 , or #including *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 or the deprecated ) 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