From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17527 invoked by alias); 24 Mar 2013 23:25:15 -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 17476 invoked by uid 48); 24 Mar 2013 23:25:07 -0000 From: "goswin-v-b at web dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56715] New: Explicit Reg Vars are being ignored for consts when using g++ Date: Sun, 24 Mar 2013 23:25: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: normal X-Bugzilla-Who: goswin-v-b at web dot de 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 X-SW-Source: 2013-03/txt/msg01721.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56715 Bug #: 56715 Summary: Explicit Reg Vars are being ignored for consts when using g++ Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: goswin-v-b@web.de Created attachment 29714 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29714 example source that experiences the bug I'm trying to pass a value to an `asm' operand using a specific register for arm with a freestanding compiler. Following the example from the info pages I have the following code: void foo() { register const int r4 asm("r4") = 0x1000; asm volatile("swi #1" : : "r"(r4)); } void bar() { register int r4 asm("r4") = 0x1000; asm volatile("swi #1" : : "r"(r4)); } Both foo() and bar() compile correct when using gcc. But when using g++ the foo() function suddenly uses the "r3" register instead of "r4". The bar() function remains correct. % arm-none-eabi-g++ -v Using built-in specs. COLLECT_GCC=arm-none-eabi-g++ COLLECT_LTO_WRAPPER=/usr/local/cross/libexec/gcc/arm-none-eabi/4.7.2/lto-wrapper Target: arm-none-eabi Configured with: ../gcc-4.7.2/configure --target=arm-none-eabi --prefix=/usr/local/cross --disable-nls --enable-languages=c,c++ --without-headers Thread model: single gcc version 4.7.2 (GCC) % arm-none-eabi-gcc -O2 -save-temps -S bug.c good code % arm-none-eabi-g++ -O2 -save-temps -S bug.c bad code ------------------------------------------------------------------ _Z3foov: .fnstart .LFB0: @ Function supports interworking. @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. mov r3, #4096 @ 3 "bug.c" 1 swi #1 @ 0 "" 2 bx lr ------------------------------------------------------------------ The source explicitly asked for "r4" but g++ uses r3 instead.