From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27496 invoked by alias); 27 Oct 2014 02:36:46 -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 Received: (qmail 27465 invoked by uid 48); 27 Oct 2014 02:36:40 -0000 From: "terra at gnome dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/63645] Incorrect code generation Date: Mon, 27 Oct 2014 03:48:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: terra at gnome dot org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.isobsolete attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-10/txt/msg02043.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63645 M Welinder changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #33809|0 |1 is obsolete| | --- Comment #11 from M Welinder --- Created attachment 33814 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33814&action=edit Updated test program I agree that C99 says that a struct around the oper member is required. That is Section 6.5.2.3 #5. It is inconvenient and probably not what the committee intended, but it is all we have. So be it. For the test program I simply grab oper out of the binary member. I haven't yet figured out how to remove valgrind from the setup. Here's what it says: ==20506== Invalid read of size 8 ==20506== at 0x4005E8: test (vvv.c:35) ==20506== by 0x4004D8: main (vvv.c:46) ==20506== Address 0x51fd040 is 0 bytes inside a block of size 1 alloc'd ==20506== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==20506== by 0x4005DA: test (vvv.c:53) ==20506== by 0x4004D8: main (vvv.c:46) Note: GnmExprBinary is back to a single member. C99's Section 6.5 #7 says that such an object can be accessed through a union that contain the type: [#7] An object shall have its stored value accessed only by an lvalue expression that has one of the following types:63) [...] -- an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), or Whatever created the error message of comment 4 therefore seems to be wrong. Unless something else disallows this. - * - I looked that the generated assembler code and here is the relevant part that shows that both the oper and func.argc fields are being tested in one go. The object doesn't have the func.argc field. .LBE4: .loc 1 35 0 movabsq $-4294967041, %rdx .LBB7: .LBB6: .loc 1 54 0 movb $0, (%rax) .LBE6: .LBE7: .loc 1 35 0 andq (%rax), %rdx movabsq $4294967297, %rcx cmpq %rcx, %rdx je .L5