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 tree-optimization/51782] New: Missing address-space information leads to wrong code


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

             Bug #: 51782
           Summary: Missing address-space information leads to wrong code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: addr-space, wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gjl@gcc.gnu.org
                CC: eric.weddington@atmel.com
            Target: avr


This is a bug with named address spaces trunk gcc 4.7 for the following source.

struct rgb { char r, g, b; };

char read_rgb_ok (const __pgm struct rgb *s)
{
    return s->r + s->g  + s->b;
}

char read_rgb_bug (const __pgm struct rgb *s)
{
    struct rgb t = *s;

    return t.r + t.g  + t.b;
}

Reading through *s must happen by means of LPM instructions (reading from
flash) and not by menas of LD instructions (reading from RAM).

However, the second function reads from RAM.


== Command Line ==

avr-gcc a-bug.c -S -Os -mmcu=avr4 -dp -fverbose-asm -v \
    -fdump-tree-optimized -fdump-tree-original -fdump-rtl-expand
-fdump-tree-gimple


== configure ==

Generated from 4.7.0 sources (HEAD) from 2012-01-03 SVN 182900

Target: avr
Configured with: ../../gcc.gnu.org/trunk/configure --target=avr
--prefix=/local/gnu/install/gcc-4.7-mingw32 --host=i386-mingw32
--build=i686-linux-gnu --enable-languages=c,c++ --disable-nls --disable-shared
--disable-lto --disable-checking --disable-libquadmath --with-dwarf2
Thread model: single
gcc version 4.7.0 20120102 (experimental) (GCC)


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