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/20194] New: gcc-4.0.0 20050220 miscompiles Linux/ppc32 kernel at -O1 and -O2


/* gcc4bug.c
 * Written by Mikael Pettersson <mikpe@csd.uu.se>, 2005-02-24.
 *
 * This program is abstracted from arch/ppc/mm/init.c in
 * the 2.6.11-rc4 Linux kernel sources.
 *
 * With gcc-3.4.3, gcc-3.3.5, or gcc-3.2.3, mem_init()
 * correctly returns 245.
 *
 * With gcc-4.0.0 20050220, mem_init() erroneously returns 0.
 * The error occurs with -O1, and -O2.
 * Compiling at -O0, or -O3 or higher, hides the error.
 *
 * All gcc versions were configured for powerpc-unknown-linux-gnu.
 */
#include <stdio.h>

#define PAGE_SIZE 4096
unsigned long PAGE_OFFSET;
unsigned long high_memory;
unsigned long etext;
unsigned long init_begin;
unsigned long init_end;
unsigned long klimit;

int mem_init(void)
{
        unsigned long addr;
        int codepages = 0;
        int datapages = 0;
        int initpages = 0;

        for (addr = PAGE_OFFSET; addr < high_memory; addr += PAGE_SIZE) {
                if (addr < etext)
                        codepages++;
                else if (addr >= init_begin && addr < init_end)
                        initpages++;
                else if (addr < klimit)
                        datapages++;
        }
        printf("datapages == %d, initpages == %d, codepages == %d\n", datapages,
initpages, codepages);
        return datapages;
}

int main(void)
{
    int datapages;

    PAGE_OFFSET = 0xc0000000;
    etext       = 0xc01bb958;
    init_begin  = 0xc0264000;
    init_end    = 0xc0288000;
    klimit      = 0xc02d4378;
    high_memory = 0xd0000000;
    datapages = mem_init();
    if (datapages != 245) {
        fprintf(stderr, "gcc bug! mem_init() returned %d\n", datapages);
        return 1;
    } else
        return 0;
}

-- 
           Summary: gcc-4.0.0 20050220 miscompiles Linux/ppc32 kernel at -O1
                    and -O2
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mikpe at csd dot uu dot se
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-unknown-linux-gnu
  GCC host triplet: powerpc-unknown-linux-gnu
GCC target triplet: powerpc-unknown-linux-gnu


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


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