public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8171: pointers to member functions comparison
@ 2002-10-08 11:06 Jozef Kosoru
  0 siblings, 0 replies; 2+ messages in thread
From: Jozef Kosoru @ 2002-10-08 11:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8171
>Category:       c++
>Synopsis:       pointers to member functions comparison
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 08 11:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jozef Kosoru <zyzstar@ibl.sk>
>Release:        3.1.1
>Organization:
>Environment:
Mandrake Linux
>Description:
g++ is not able to compile the following code:

----------------------------------------------------
#include <iostream>
using namespace std;

struct A
{
    int f() {}
};

struct B : A
{
};

int main()
{
    int (A::*pa)() = &A::f;
    int (B::*pb)() = &B::f;

    cout << boolalpha << (pa == pb) << endl;
}
----------------------------------------------------

...but according to ISO (see 5.10/2) this code should compile and result of the pointer comparsion would be 'true'.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/8171: pointers to member functions comparison
@ 2002-11-04  8:15 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2002-11-04  8:15 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, zyzstar

Synopsis: pointers to member functions comparison

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Nov  4 08:15:06 2002
State-Changed-Why:
    I agree. In particular, the referenced part of the standard
    states:
      Pointer  to  member  conversions(_conv.mem_) and
      qualification conversions (_conv.qual_) are performed
      to bring them to a common type.
    This does not seem to happen. (Conversion by hand yields
    the desired result though, so there is a way to work
    around this problem.)
    
    W.
    
    
    PS: As a sidenote (for the curious), the standard also says
    this on comparing pointers to member functions:
      if either [operand] is a pointer to a virtual  member  func-
      tion,  the result is unspecified
    That seems like a trap you don't want to fall into... (And
    there isn't even a way for the compiler to warn you about.)
    
    

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8171


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

end of thread, other threads:[~2002-11-04 16:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-08 11:06 c++/8171: pointers to member functions comparison Jozef Kosoru
2002-11-04  8:15 bangerth

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