From mboxrd@z Thu Jan 1 00:00:00 1970 From: jan@etpmod.phys.tue.nl To: gcc-gnats@gcc.gnu.org Subject: c++/3747: ambiguity between `T operator[](unsigned)` and `T* operator` Date: Fri, 20 Jul 2001 08:16:00 -0000 Message-id: <20010720151223.21337.qmail@sourceware.cygnus.com> X-SW-Source: 2001-07/msg00550.html List-Id: >Number: 3747 >Category: c++ >Synopsis: ambiguity between `T operator[](unsigned)` and `T* operator` >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Fri Jul 20 08:16:03 PDT 2001 >Closed-Date: >Last-Modified: >Originator: jan@etpmod.phys.tue.nl >Release: gcc version 3.0 >Organization: >Environment: Linux 2.4.6, Configured with: ../../src/egcs-3.0/configure --enable-version-specific-runtime-libs --prefix=/usr/local/egcs-3.0 >Description: The attached code (file strtest.cpp) fails to compile with egcs version 3.0 (or with the head branch). This is a regression wrt 2.95.x Gcc-3.0:pcjan:/home/jan/src>g++ -c strtest.cpp strtest.cpp:6: choosing `char& A::operator[](unsigned int)' over `operator[]' strtest.cpp:6: because worst conversion for the former is better than worst conversion for the latter The compiler is in doubt: it cannot choose between A.operator[](0) and A.(operator const char*).`c-builtin[]`(0). IMHO the first conversion has preference and should be chosen. >How-To-Repeat: Compile the attached file strtest.cpp >Fix: This bug breaks existing code, I could not think of a transparent workaround. If `0' is replaced with `0u' (unsigned 0), the snippet compiles properly. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/x-c++src; name="strtest.cpp" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="strtest.cpp" c3RydWN0IEEgewoJY2hhciBvcGVyYXRvcltdKHVuc2lnbmVkKSBjb25zdDsKCW9wZXJhdG9yIGNv bnN0IGNoYXIqKCkgY29uc3Q7Cn07CkEgczsKY2hhciBjPXNbMHVdOwo=