From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12980 invoked by alias); 31 Mar 2003 09:56:09 -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 12959 invoked by uid 71); 31 Mar 2003 09:56:07 -0000 Resent-Date: 31 Mar 2003 09:56:07 -0000 Resent-Message-ID: <20030331095607.12958.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, darrenr@optimation.com.au Received: (qmail 8564 invoked by uid 48); 31 Mar 2003 09:51:31 -0000 Message-Id: <20030331095131.8563.qmail@sources.redhat.com> Date: Mon, 31 Mar 2003 10:04:00 -0000 From: darrenr@optimation.com.au Reply-To: darrenr@optimation.com.au To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/10273: g++ fails to compile sort() with a template operator that takes a pointer X-SW-Source: 2003-03/txt/msg02095.txt.bz2 List-Id: >Number: 10273 >Category: c++ >Synopsis: g++ fails to compile sort() with a template operator that takes a pointer >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Mar 31 09:56:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: darrenr@optimation.com.au >Release: unknown-1.0 >Organization: >Environment: Linux linux 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux >Description: % g++ --version g++ (GCC) 3.3 20030331 (prerelease) % uname -a Linux linux 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux The following code does not compile with the above version with g++. The error message seen is as follows: % g++ foo.cpp foo.cpp: In function `void std::doit()': foo.cpp:31: error: type/value mismatch at argument 1 in template parameter list for `template > struct std::xLess' foo.cpp:31: error: expected a constant of type `std::ClassName*', got ` std::ClassName*' If the code is wrong then the error message is wrong. However, if I add this line: typedef ClassName * ClassNamePtr; and change all references of "ClassName *" to "ClassNamePtr", I now get an error about "x being private to ClassName (seems wrong also?) and finally making x public gets rid of all errors. This is just a code sample to show the problem, unfortunately the I'm not able to do the typedef thing in the application for other reasons :-( #include #include #include namespace std { class ClassName { public: ClassName(int n) { x = n; } private: int x; }; template struct xLess : binary_function { bool operator()(const ClassName *& T1, const ClassName *& T2) const { return T1->x < T2->x; } }; void doit() { vector a; a.push_back(new ClassName(1)); a.push_back(new ClassName(2)); a.push_back(new ClassName(5)); sort(a.begin(), a.end(), xLess()); } }; int main(int argc, char *argv[]) { std::doit(); return 0; } >How-To-Repeat: See description. >Fix: >Release-Note: >Audit-Trail: >Unformatted: