From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9776 invoked by alias); 25 Feb 2014 19:45:52 -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 9710 invoked by uid 48); 25 Feb 2014 19:45:49 -0000 From: "arthur.j.odwyer at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/36043] gcc reads 8 bytes for a struct of size 6 which leads to sigsegv Date: Tue, 25 Feb 2014 19:45:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.3.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: arthur.j.odwyer at gmail dot com X-Bugzilla-Status: NEW 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: cc 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-02/txt/msg02543.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36043 Arthur O'Dwyer changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.j.odwyer at gmail dot com --- Comment #22 from Arthur O'Dwyer --- Here's another segfaulting test case, for x86-64. This fails with GCC 4.6.2 and GCC 4.8.1. This GCC bug is really hard to work around, since it can strike anywhere without warning. Is it possible that one of the patches above (e.g., Richard Biener's comment #9) could be adopted into 4.8.x or 4.9.x? #include #include #include struct int24_t { uint8_t m_Internal[3]; }; void foo(int24_t a) { puts("2"); } int main() { const int OS_PAGE_SIZE = 0x1000; const int COUNT = (OS_PAGE_SIZE) / sizeof(int24_t); printf("sizeof int24_t = %d\n", (int)sizeof(int24_t)); void* arena1 = mmap(0, OS_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); int24_t* ptr = (int24_t*)mmap(0, OS_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); munmap(arena1, OS_PAGE_SIZE); puts("1"); foo(ptr[COUNT-1]); puts("3"); }