public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3830: compile error, if a class has operator[] and operator char*()
@ 2001-10-16 5:34 billingd
0 siblings, 0 replies; 2+ messages in thread
From: billingd @ 2001-10-16 5:34 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, jan, martin.gerbershagen, nobody
Synopsis: compile error, if a class has operator[] and operator char*()
State-Changed-From-To: open->closed
State-Changed-By: billingd
State-Changed-When: Tue Oct 16 05:34:15 2001
State-Changed-Why:
Duplicate of 3747
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3830&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/3830: compile error, if a class has operator[] and operator char*()
@ 2001-07-26 5:46 martin.gerbershagen
0 siblings, 0 replies; 2+ messages in thread
From: martin.gerbershagen @ 2001-07-26 5:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 3830
>Category: c++
>Synopsis: compile error, if a class has operator[] and operator char*()
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Jul 26 05:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Martin Gerbershagen
>Release: gcc-3.0
>Organization:
>Environment:
>Description:
When the attached code is compiled with g++ -c the following
error message is issued:
bug.C: In function `void x()':
bug.C:20: choosing `char& A::operator[](unsigned int)' over `operator[]'
bug.C:20: because worst conversion for the former is better than worst
conversion for the latter
bug.C:20: choosing `char& A::operator[](unsigned int)' over `operator[]'
bug.C:20: because worst conversion for the former is better than worst
conversion for the latter
This error is wrong, the code is legal code.
>How-To-Repeat:
class A {
char *p;
public:
char operator[](unsigned int i) const {
return p[i];
}
char& operator[](unsigned int i) {
return p[i];
}
operator char*() {
return p;
}
operator const char*() const {
return p;
}
};
void x() {
A a;
char c = a[1];
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-10-16 5:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-16 5:34 c++/3830: compile error, if a class has operator[] and operator char*() billingd
-- strict thread matches above, loose matches on Subject: below --
2001-07-26 5:46 martin.gerbershagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).