This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17972] [3.4 Regression] const/pure functions result in bad asm
- From: "mostrows at watson dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Feb 2005 14:18:49 -0000
- Subject: [Bug c++/17972] [3.4 Regression] const/pure functions result in bad asm
- References: <20041013124723.17972.mostrows@watson.ibm.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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