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

            Bug ID: 60075
           Summary: Wrong code from loop optimizer with address-space
                    accesses
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gjl at gcc dot gnu.org

Created attachment 32046
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32046&action=edit
loop-memx.c: C source triggering the bug

The following C code runs to abort:

== C code ==

typedef unsigned char uint8_t;

volatile uint8_t buf[12];
volatile uint8_t buf_used;

void __attribute__((noinline,noclone))
copy_string (uint8_t len, const __memx char* str)
{
    uint8_t n;

    for (n = 0; n < len; n++)
    {
        if (*str != '1')
            __builtin_abort();
        buf[n] = *str++;
    }

    buf_used = len;
}

int main (void)
{
    copy_string (1, "1");

    return 0;
}

== Command Line ==

$ avr-gcc -mmcu=atmega128 loop-memx.c -O2 -v

== Configuration ==

It's from the current (2014-02-05) 4.7 head but the problem is also known for
official releases like 4.7.2

gcc version 4.7.4 20140205 (prerelease) [gcc-4_7-branch revision 195858] (GCC)

Target: avr
Configured with: ../../gcc.gnu.org/gcc-4_7-branch/configure --target=avr
--prefix=/local/gnu/install/gcc-4.7 --disable-nls --with-dwarf2
--enable-languages=c,c++ --enable-target-optspace=yes --with-avrlibc=yes

Reply via email to