From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28978 invoked by alias); 19 Jan 2011 09:00:29 -0000 Received: (qmail 28909 invoked by uid 22791); 19 Jan 2011 09:00:27 -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; Wed, 19 Jan 2011 09:00:22 +0000 From: "yottui at yahoo dot co.jp" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/47357] New: volatile member function is not treated as volatile 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: normal X-Bugzilla-Who: yottui at yahoo dot co.jp 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" MIME-Version: 1.0 Date: Wed, 19 Jan 2011 09:56:00 -0000 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-01/txt/msg01899.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47357 Summary: volatile member function is not treated as volatile Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: yottui@yahoo.co.jp When I execute the following test code with '-O2 -msse2' compiler options, it outputs the wrong value. I'm expecting that pC[1] will be 2. operator[](int) is defined as volatile. However v is not treated as volatile. And I tried (volatile const u &) instead of (const u &) when the casting, but it's not affected. -- begin test case -- //g++ -O2 -msse2 test.cpp #include #include #include #define NELEM 1 struct int4 { __m128i v; int4(__m128i a) : v(a) {} int4(int a0, int a1, int a2, int a3) : v(_mm_setr_epi32(a0, a1, a2, a3)) {} operator __m128i() const { return v; } int operator [](int i) volatile const { union u { __m128i m128; int i32[4]; }; return ((const u &)v).i32[i]; } }; inline int4 operator <<(const int4 & a, const int4 & b) { return int4(a[0]<