From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8572 invoked by alias); 29 Apr 2003 16:26:01 -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 8535 invoked by uid 71); 29 Apr 2003 16:26:00 -0000 Resent-Date: 29 Apr 2003 16:26:00 -0000 Resent-Message-ID: <20030429162600.8533.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, gianni@mariani.ws Received: (qmail 7841 invoked by uid 48); 29 Apr 2003 16:24:47 -0000 Message-Id: <20030429162447.7840.qmail@sources.redhat.com> Date: Tue, 29 Apr 2003 16:26:00 -0000 From: gianni@mariani.ws Reply-To: gianni@mariani.ws To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/10542: warning: choosing `T::operator int&()' over `T::operator const int&() const' X-SW-Source: 2003-04/txt/msg01350.txt.bz2 List-Id: >Number: 10542 >Category: c++ >Synopsis: warning: choosing `T::operator int&()' over `T::operator const int&() const' >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Apr 29 16:26:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: gianni@mariani.ws >Release: GCC 3.2.2 >Organization: >Environment: Linux RH 8.0 configure --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit Thread model: posix gcc version 3.2.2 >Description: The warnings below ahould not be issued. The code below should work without problems. g++ tt5.cpp -o tt5 tt5.cpp: In function `int main()': tt5.cpp:53: warning: choosing `IType::operator int&()' over `IType::operator const int&() const' tt5.cpp:53: warning: for conversion from `IType' to `int' tt5.cpp:53: warning: because conversion sequence for the argument is better #include class IType { public: int m_value; inline IType() : m_value( 3322-21 ) { } inline operator int & () { return m_value; } inline operator const int & () const { return m_value; } inline int & operator = ( const int & i_value ) { m_value = i_value; return m_value; } }; class tester { public: IType m_int; }; int main() { tester z; const tester * a = & z; assert( z.m_int == 3301 ); assert( a->m_int == 3301 ); return 0; } >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: