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

            Bug ID: 57835
           Summary: variable tracking produces weird const
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Target: mips64-linux-gnu

Take:
 typedef unsigned int uint32_t;
 unsigned char from_ucs4[0x1000] = {0,1};
to_cp1258_single (const unsigned char **inptrp) {
   const unsigned char *inptr = *inptrp;
  uint32_t ch = *((const uint32_t *) (inptr));
   unsigned char res;
   if (ch < 50) res = from_ucs4[ch];
  else
     res = from_ucs4[ch - 100];
  if (res != 0)
    if (ch)
     for (;;) { }
 }
--- CUT ---
Compile with -mabi=n32 -O2 -g and it produces:
        .4byte  from_ucs4-100

This is due to variable tracking producing:
(note 109 26 98 8 (var_location res (mem/j:QI (plus:SI (reg/v:SI 2 $2 [orig:196
ch ] [196])
        (const:SI (plus:SI (symbol_ref:SI ("from_ucs4") [flags 0x2]  <var_decl
0x7f5d36092000 from_ucs4>)
                (const_int -100 [0xffffffffffffff9c])))) [0 from_ucs4 S1 A8]))
NOTE_INSN_VAR_LOCATION)

I don't think we should have wrapped a const around this kind of plus.

Reply via email to