From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25472 invoked by alias); 1 Apr 2003 02:36:00 -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 25458 invoked by uid 71); 1 Apr 2003 02:36:00 -0000 Date: Tue, 01 Apr 2003 02:36:00 -0000 Message-ID: <20030401023600.25457.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Wolfgang Bangerth Subject: RE: c++/10273: g++ fails to compile sort() with a template operator that takes a pointer Reply-To: Wolfgang Bangerth X-SW-Source: 2003-04/txt/msg00003.txt.bz2 List-Id: The following reply was made to PR c++/10273; it has been noted by GNATS. From: Wolfgang Bangerth To: "Darren Reed (OSE)" Cc: gcc-bugs@gcc.gnu.org, Subject: RE: c++/10273: g++ fails to compile sort() with a template operator that takes a pointer Date: Mon, 31 Mar 2003 20:26:00 -0600 (CST) > > x.cc: In function `void std::doit()': > > x.cc:31: type/value mismatch at argument 1 in template parameter list for ` > > template > struct std::xLess' > > x.cc:31: expected a constant of type `std::ClassName*', got `std::ClassName*' > > > > I think the message says it quite clearly: first the type/value mismatch, > > then in addition that it expected a value and got a type. What more do you > > want? > > Ok, so you know how to parse that message better than I do. To me it says > "expected type 'A', got 'A'" (where A is "std::ClassName*") and hence it > does not make any sense to me. No, read it, it says expected a constant [i.e. a value] of type 'X', got 'X' [which is a type] The situation is the same as if you had written template class X{}; and then used it as X x; That won't work. > I'm the programmer, so because I don't > intend for there to be a value there, I don't see a value there. If you intend there to be a type, then you should declare the template as taking a type, rather than a value. > The error > doesn't tell me that using * implies a value is being used in a template > where a type should be. What you wrote was template struct X {}; which, since ClassName is the name of an existing class, is equivalent to template struct X {}; (that is just the same as declaring variables as "struct X x;" or "X x;" is equivalent in C++.) > Just for the sake of comparison, I tried compiling the same piece of code > with Visual Studio .Net and SUNWspro CC. Both of those compilers (rightly > or wrongly, I don't know) complain about the code when it comes to parsing > the template statement. In my situation, this type of verbosity helps. > [...verbosity of other compilers deleted...] These compilers simply don't realize that template struct X {}; and template W. ------------------------------------------------------------------------- Wolfgang Bangerth email: bangerth@ticam.utexas.edu www: http://www.ticam.utexas.edu/~bangerth/