This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/21135] [4.0/4.1 Regression] &a[-2] ICE at the top level


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-26 03:48 -------
Here is an interesting thing:
if we do:
int f[3];

int *h(void)
{
  return &f[-1];
}
---
The C front-end expands it like:
(insn 10 9 11 (set (reg:SI 60)
        (const_int -4 [0xfffffffc])) -1 (nil)
    (nil))

(insn 11 10 12 (parallel [
            (set (reg:SI 59)
                (plus:SI (reg:SI 60)
                    (symbol_ref:SI ("f") <var_decl 0xb7c630b0 f>)))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil)
    (nil))

(insn 12 11 13 (set (reg:SI 58 [ <result> ])
        (reg:SI 59)) -1 (nil)
    (nil))

But the C++ front-end does:
(insn 10 9 11 (set (reg:SI 60)
        (symbol_ref:SI ("f") [flags 0x2] <var_decl 0xb7cbb1b8 f>)) -1 (nil)
    (nil))

(insn 11 10 12 (parallel [
            (set (reg:SI 59)
                (plus:SI (reg:SI 60)
                    (const_int -4 [0xfffffffc])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil)
    (nil))

(insn 12 11 13 (set (reg:SI 58 [ <result> ])
        (reg:SI 59)) -1 (nil)
    (nil))

Notice how the the order of the plus happens.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21135


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]