From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24021 invoked by alias); 18 Jun 2006 23:34:47 -0000 Received: (qmail 24013 invoked by uid 22791); 18 Jun 2006 23:34:46 -0000 X-Spam-Check-By: sourceware.org Received: from mk-smarthost-2.mail.uk.tiscali.com (HELO mk-smarthost-2.mail.uk.tiscali.com) (212.74.114.38) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 18 Jun 2006 23:34:43 +0000 Received: from 88-105-176-119.dynamic.dsl.as9105.com (HELO mk-smarthost-8.mail.uk.tiscali.com) ([88.105.176.119]) by mk-smarthost-2.mail.uk.tiscali.com with ESMTP; 19 Jun 2006 00:34:27 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AY8CABh7lUSJZg Received: from 88-105-176-119.dynamic.dsl.as9105.com ([88.105.176.119]:1678 helo=[192.168.0.2]) by mk-smarthost-8.mail.uk.tiscali.com with esmtp (Exim 4.30) id 1Fs2Ye-000Axt-60 for gcc-help@gcc.gnu.org; Sun, 18 Jun 2006 19:03:40 +0000 Message-ID: <4495A449.9080605@tiscali.co.uk> Date: Sun, 18 Jun 2006 23:34:00 -0000 From: Andrew McLean User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Error message for 'ambiguous overload for operator>>' in gcc 4.1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2006-06/txt/msg00144.txt.bz2 I have program that builds and runs OK when using gcc 3.3.5, but gets an error when built with gcc 4.1.0. For now, I'll just pick out what seem to be the salient fragments... palette.h Class definitions etc. The Class 'palette' includes the following fragment: '...' indicates other lines omitted for clarity. --------------- { ... private: ... long used; }; --------------- palette.cpp Member functions etc. This file includes code sections ('functors' ?) to overload the '>>' and '<<' operators. These allow 'palette' objects to be written to and read back from a simple text file. One such section includes the following: --------------- std::istream &operator >> (std::istream &str, const Palette &pal) { str >> pal.used; [*** error here] ... return str; } ----------------- With gcc 4.1.0, the line marked 'error here' generates this error message: palette.cpp:204: error: ambiguous overload for 'operator>>' in 'str >> pal->Palette::used' and it then lists four alternative definitions for '>>' from the 'istream' file, which it can't choose between. I found I could kludge the problem by making 'used' an array, and just using the first element. The obvious questions are: 1. What is the 'best' way to clear this error ? 2. What changed in gcc 4.x to trigger this problem ? I had a quick trawl through the gcc website but didn't spot anything that looked relevant. AM