public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3601: GCC 3.0 barfs on overloaded operator==
@ 2001-07-06 22:06 markus_schoder
  0 siblings, 0 replies; 2+ messages in thread
From: markus_schoder @ 2001-07-06 22:06 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3601
>Category:       c++
>Synopsis:       GCC 3.0 barfs on overloaded operator==
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 06 22:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Markus Schoder
>Release:        gcc-3.0 gcc-3.0-20010626
>Organization:
>Environment:
Linux i386
>Description:
Compilation of the attached program gives the following error:

eqtempl.cpp: In function `bool g(A)':
eqtempl.cpp:14: choosing `bool operator==(A, void*)' over `operator=='
eqtempl.cpp:14:   because worst conversion for the former is better than worst 
   conversion for the latter

I do not see how there is a conversion involved for bool operator==(A, void*).  0 needs not be "converted" to void* in C++.  However with an explicit conversion to void* it compiles.

It also compiles when -fpermissive is given as an option but this should not be needed.
>How-To-Repeat:
Compile attached program (without linking)
>Fix:
A workaround is to use an explicit cast like:

a == (void*)0

or specify -fpermissive as a command line option.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="eqtempl.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="eqtempl.cpp"

c3RydWN0IEEKewogIG9wZXJhdG9yIGJvb2woKSB7IHJldHVybiBwOyB9OwogIHZvaWQgKnA7Cn07
Cgpib29sIG9wZXJhdG9yPT0oQSB4LCB2b2lkICp5KQp7CiAgcmV0dXJuIHgucCA9PSB5Owp9Cgpi
b29sIGcoQSBhKQp7CiAgcmV0dXJuIGEgPT0gMDsKfQo=


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/3601: GCC 3.0 barfs on overloaded operator==
@ 2001-07-07  6:19 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2001-07-07  6:19 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, markus_schoder, nobody

Synopsis: GCC 3.0 barfs on overloaded operator==

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Jul  7 06:19:33 2001
State-Changed-Why:
    Not a bug.  According to the standard Sectio 4.10 (Pointer
    conversions) paragraph 1:
      A null pointer constant is an integral constant expression
      (5.19) rvalue of integer type that evaluates to zero.  A
      null pointer constant can be converted to a pointer type;
      the result is the null pointer value of that type and is
      is distinguishable from every other value of pointer to
      object or pointer to function type. ...
    
    Here 0 is "null pointer constant" and has to be converted
    to "null pointer value" of type "void *".

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3601&database=gcc


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-07  6:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-06 22:06 c++/3601: GCC 3.0 barfs on overloaded operator== markus_schoder
2001-07-07  6:19 lerdsuwa

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).