From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7732 invoked by alias); 2 Feb 2004 16:49:09 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 7717 invoked from network); 2 Feb 2004 16:49:07 -0000 Received: from unknown (HELO CLEMSON.EDU) (130.127.28.87) by sources.redhat.com with SMTP; 2 Feb 2004 16:49:07 -0000 Received: from [130.127.153.82] (rhodes153dhcp82.ces.clemson.edu [130.127.153.82]) (authenticated bits=0) by CLEMSON.EDU (8.12.8p1-20030924/8.12.8) with ESMTP id i12GmtRN022121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 2 Feb 2004 11:48:56 -0500 (EST) Subject: Problem with templates and operator overloading From: Casey Goodlett Reply-To: cgoodle@CLEMSON.EDU To: gcc-help@gcc.gnu.org Content-Type: text/plain Organization: Center For Advanced Engineering of Fibers and Films Message-Id: <1075740536.2151.17.camel@rhodes153dhcp82.ces.clemson.edu> Mime-Version: 1.0 Date: Mon, 02 Feb 2004 16:49:00 -0000 Content-Transfer-Encoding: 7bit X-SW-Source: 2004-02/txt/msg00012.txt.bz2 I'm having trouble with the following piece of c++ code. Is this a bug in gcc or am I doing something wrong? The code compiles and runs without problems in icc. GCC Version: 3.3.2 struct doubler { double operator*(double val) { return 2.0 * val; } }; template T operator*(double lhs , T rhs) { return rhs * lhs; } int main() { doubler a; a * 3.0; return 0; } Compiling this gives the following error message. test3.cc: In function `T operator*(double, T)': test3.cc:7: error: `T operator*(double, T) [with T = double]' must have an argument of class or enumerated type Thanks. -- Casey Goodlett (cgoodle@clemson.edu)