BUG: egcs C++ compiler compiles ill-formed code? (fwd)
Mumit Khan
khan@xraylith.wisc.edu
Wed Sep 16 13:51:00 GMT 1998
---------- Forwarded message ----------
Date: Wed, 16 Sep 1998 13:41:16 -0500
From: Thanatos <fvali@biotrack.com>
To: khan@biotrack.com
Subject: BUG: egcs C++ compiler compiles ill-formed code?
According to the standard draft CD2:
"5.3.1 Unary operators [expr.unary.op]
...
3 A pointer to member is only formed when an explicit & is used and its
operand is a qualified-id not enclosed in parentheses. [Note: that
is, the expression &(qualified-id), where the qualified-id is enclosed
----------------------------------------------------------------------
in parentheses, does not form an expression of type "pointer to mem-
ber." Neither does qualified-id, because there is no implicit conver-
sion from a qualified-id for a nonstatic member function to the type
"pointer to member function" as there is from an lvalue of function
type to the type "pointer to function" (_conv.func_). Nor is &unqual-
ified-id a pointer to member, even within the scope of the unquali-
fied-id's class. ]"
Thus according to the above paragraph this code is ill-formed:
struct A
{
void f() { };
};
void (A::*pf)() = &(A::f); //Error, because parenthesized
void (A::*pf)() = &A::f; //Well-formed.
egcs 1.1 c++/g++ both compile the parenthesized version!
Please do reply and lemme know if this actually is a bug, or has been
corrected in the C++ standard, since the draft.
I really would appreciate the feedback, however brief it might be :-)
-thanks
-fais
--
Biometric Applications & Technology
Faisal Vali - Software Engineer (B.A.T man)
----------------------------------------------------
To be a philosopher is not merely to have subtle thoughts, nor even to
found
a school, but so to love wisdom as to live according to its dictates a
life of
simplicity, independence, magnanimity, and trust. It is to solve some of
the
problems of life, not only theoretically, but practically. (Henry David
Thoreau)
More information about the Gcc-bugs
mailing list