From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29752 invoked by alias); 24 Feb 2005 14:19:07 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29557 invoked by uid 48); 24 Feb 2005 14:18:49 -0000 Date: Thu, 24 Feb 2005 17:10:00 -0000 Message-ID: <20050224141849.29556.qmail@sourceware.org> From: "mostrows at watson dot ibm dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041013124723.17972.mostrows@watson.ibm.com> References: <20041013124723.17972.mostrows@watson.ibm.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17972] [3.4 Regression] const/pure functions result in bad asm X-Bugzilla-Reason: CC X-SW-Source: 2005-02/txt/msg02966.txt.bz2 List-Id: ------- Additional Comments From mostrows at watson dot ibm dot com 2005-02-24 14:18 ------- New test case exhibits same problem. struct demo { int s; }; extern struct demo * const *xd; static inline struct demo *fn1(void) __attribute__((pure)); static inline struct demo *fn1(void) { struct demo { int s; }; extern struct demo * const *xd; static inline struct demo *fn1(void) __attribute__((pure)); static inline struct demo *fn1(void) { struct demo **d; return *xd; } unsigned long foo() { unsigned long old = 0; old = (fn1()->s) & (((1UL << (8))-1) << 0); (fn1()->s) -= old; return old; } Here's how the generated code looks like, note the branch to self. mostrows@heater:/tmp$ /opt/crosstool/bin/powerpc64-linux-gcc -x c++ -O -c /tmp/bug.C -S -o - .file "bug.C" .section ".text" .align 2 .globl _Z3foov .section ".opd","aw" .align 3 _Z3foov: .quad ._Z3foov,.TOC.@tocbase,0 .previous .size _Z3foov,24 .type ._Z3foov,@function .globl ._Z3foov ._Z3foov: .LFB3: .L3: b .L3 .long 0 .byte 0,9,0,0,0,0,0,0 .LFE3: .size ._Z3foov,.-._Z3foov .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.4.4 20050211 (prerelease)" Specifying language as "C" instead of C++ results in correct code generation. -- What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17972