http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50282
Bug #: 50282 Summary: pointer-to-member cast works incorrectly Classification: Unclassified Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: imzh...@vip.qq.com Created attachment 25180 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25180 compile-info (command line, and g++ output), t.cpp (source), t.ii in ISO/IEC 14882 (cpp2003) <also in n3224(cpp0x)>, chapter 5.2.10 about reinterpret_cast, the rule 9 says: " An rvalue of type “pointer to member of X of type T1” can be explicitly converted to an rvalue of type “pointer to member of Y of type T2” if T1 and T2 are both function types or both object types.66) The null member pointer value (4.11) is converted to the null member pointer value of the destination type. The result of this conversion is unspecified, except in the following cases: — converting an rvalue of type “pointer to member function” to a different pointer to member function type and back to its original type yields the original pointer to member value. — converting an rvalue of type “pointer to data member of X of type T1” to the type “pointer to data member of Y of type T2” (where the alignment requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer to member value. " but as i tested using G++ 4.1.2 (SUSE LINUX 11) / G++ 4.5.5 (UBUNTU 11.04), this is not exactly implemented. detailed comments are in the attachments. attachment: 1.compile info.txt 2.t.ii /test-case ii file 3.tiny single test-case source-file which includes ONLY c++ standered headers, detailed commented.