From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 704 invoked by alias); 3 Sep 2011 07:39:26 -0000 Received: (qmail 660 invoked by uid 22791); 3 Sep 2011 07:39:24 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Sep 2011 07:39:11 +0000 From: "imzhuli at vip dot qq.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/50282] New: pointer-to-member cast works incorrectly Date: Sat, 03 Sep 2011 07:39:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: imzhuli at vip dot qq.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00195.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D50282 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: unassigned@gcc.gnu.org ReportedBy: imzhuli@vip.qq.com Created attachment 25180 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=3D25180 compile-info (command line, and g++ output), t.cpp (source), t.ii in ISO/IEC 14882 (cpp2003) , chapter 5.2.10 about reinterpret_cast, the rule 9 says: " An rvalue of type =E2=80=9Cpointer to member of X of type T1=E2=80=9D can b= e explicitly converted to an rvalue of type =E2=80=9Cpointer to member of Y of type T2=E2=80=9D if T1 and T2 are both f= unction 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: =E2=80=94 converting an rvalue of type =E2=80=9Cpointer to member function= =E2=80=9D to a different pointer to member function type and back to its original type yields the original pointer to member va= lue. =E2=80=94 converting an rvalue of type =E2=80=9Cpointer to data member of X= of type T1=E2=80=9D to the type =E2=80=9Cpointer to data member of Y of type T2=E2=80=9D (where the alignment requirements of T2 are no str= icter 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),= =20 this is not exactly implemented.=20 detailed comments are in the attachments. attachment: 1.compile info.txt=20 2.t.ii /test-case ii file 3.tiny single test-case source-file which includes ONLY c++ standered heade= rs, detailed commented.