From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100544 invoked by alias); 22 Mar 2015 05:34:44 -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 100471 invoked by uid 48); 22 Mar 2015 05:34:36 -0000 From: "maltsevm at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65507] avr-gcc -f-merge-all-constants causes internal compiler error in get_section, at varasm.c:312 Date: Sun, 22 Mar 2015 09:56:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: maltsevm at gmail dot 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-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: 2015-03/txt/msg02239.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65507 Mikhail Maltsev changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maltsevm at gmail dot com --- Comment #2 from Mikhail Maltsev --- On current trunk GCC does not ICE, but still sort-of-rejects the valid code. Reduced testcase: $ cat ./reduced2.c void foobar() { static const char c1[] __attribute__((__progmem__)) = "1", c2[] __attribute__((__progmem__)) = "2", c3[] = "3"; } /opt/binutils-avr/bin/avr-gcc -c -fmerge-all-constants ./reduced2.c ./reduced2.c:5:1: error: section type conflict } Despite the error, assembly code (and object file) are still produced, though it seems to me, that section information gets trashed, but I'm not sure. Looks like this: .section .rodata.str1.1,"aMS",@progbits,1 .type c3.1570, @object .size c3.1570, 2 c3.1570: .string "3" .section .progmem.data.str1.1 .type c2.1569, @object .size c2.1569, 2 c2.1569: .string "2" .type c1.1568, @object .size c1.1568, 2 c1.1568: .string "1" Without "-fmerge-all-constants" I get the following: .size foobar, .-foobar .section .rodata .type c3.1570, @object .size c3.1570, 2 c3.1570: .string "3" .section .progmem.data,"a",@progbits .type c2.1569, @object .size c2.1569, 2 c2.1569: .string "2" .type c1.1568, @object .size c1.1568, 2 c1.1568: .string "1" The problem occurs when GCC tries to get the section for c1 and calls avr_asm_select_section. This function changes the section name from ".rodata.data.str1.1" to ".progmem.data.str1.1", it then turns out that this section already exists and the check in varasm.c:get_section fails (both sections have same flags, SECTION_DECLARED is true, SECTION_OVERRIDE is false, SECTION_WRITE is false - this all triggers an error). This comment seems relevant: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43746#c8.