------- 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.

[EMAIL PROTECTED]:/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,[EMAIL PROTECTED],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

Reply via email to