public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32416] New: pointer-to-member stuff inconsistently compiled without warning
@ 2007-06-20 12:36 emmanuel dot garcia at infoterra dot fr
2007-06-20 13:44 ` [Bug c++/32416] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: emmanuel dot garcia at infoterra dot fr @ 2007-06-20 12:36 UTC (permalink / raw)
To: gcc-bugs
I. CODE SAMPLE
#include <stdio.h>
#define SHOWBUG
class A;
class F
{
public:
F(A *x, void (A::*y)()) : m_x(x), m_y(y) {}
void operator()();
private:
A *m_x;
void (A::*m_y)();
};
#ifdef SHOWBUG
void F::operator()() { (m_x->*m_y)(); }
#endif
class A
{
public:
void f() { printf("A::f()\n"); }
};
#ifndef SHOWBUG
void F::operator()() { (m_x->*m_y)(); }
#endif
int main()
{
A x;
F f(&x, &A::f);
f();
}
II. EXPLANATION
A is a class that has a method void f().
F is a class that wraps a void(A::*)() method.
The program creates an A object, then it creates an F object
that wraps the void f() method of the created A object,
then it invokes operator() of the F object.
The expected behaviour is that invoking the operator() of the F object
should trigger the invocation of the f() method of the wrapped A object
(which would print something on the console).
The observed behaviour is that the A::f() method sometimes is invoked
(as expected) and sometimes is not invoked (incorrect?).
Whether the A::f() is correctly invoked by invoking the F::operator()
method depends on the respective order in which class A and F::operator()
are defined.
By setting #define SHOWBUG, the A::f() is not invoked.
By setting #undef SHOWBUG, the A::f() is invoked (as expected).
The problem is that in both cases the code compiles fine with no warning
whatsoever (even with -Wall).
--
Summary: pointer-to-member stuff inconsistently compiled without
warning
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: emmanuel dot garcia at infoterra dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32416
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/32416] pointer-to-member stuff inconsistently compiled without warning
2007-06-20 12:36 [Bug c++/32416] New: pointer-to-member stuff inconsistently compiled without warning emmanuel dot garcia at infoterra dot fr
@ 2007-06-20 13:44 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-20 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-06-20 13:44 -------
*** This bug has been marked as a duplicate of 15684 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32416
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-20 13:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-20 12:36 [Bug c++/32416] New: pointer-to-member stuff inconsistently compiled without warning emmanuel dot garcia at infoterra dot fr
2007-06-20 13:44 ` [Bug c++/32416] " pinskia at gcc dot gnu dot org
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).