Is this an optimizer bug?
From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: 05/31/05
- Next message: Arun Prasad Velu: "Re: Urgent Requirement for Linux Developers!"
- Previous message: Josef Moellers: "Re: how to write a program like top, whose output keep the line number constant"
- Next in thread: Basile Starynkevitch [news]: "Re: Is this an optimizer bug?"
- Reply: Basile Starynkevitch [news]: "Re: Is this an optimizer bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 May 2005 09:19:59 +0200
If I compile this program with -O2, the write statement
is executed only once. If I compile it with -O1 the write
statement is executed multiple times as expected.
Looks like an optimizer bug to me. Did I miss something?
I'm running FC1 with kernel version 2.4.22-1.2199.nptl
and gcc version 3.3.2-1.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#define PAGESIZE (1<<12)
#define PAGES (1<<18)
int main()
{
int i;
char *mem;
mem=mmap(NULL,PAGESIZE*PAGES,PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS,0,0);
if (mem==MAP_FAILED) {
perror("mmap");
return EXIT_FAILURE;
}
for (i=0;i<PAGES;++i)
if (write(1,mem+i*PAGESIZE,PAGESIZE)<1) {
perror("write");
return EXIT_FAILURE;
}
return 0;
}
-- Kasper Dupont -- der bruger for meget tid på usenet. Note to self: Don't try to allocate 256000 pages with GFP_KERNEL on x86.
- Next message: Arun Prasad Velu: "Re: Urgent Requirement for Linux Developers!"
- Previous message: Josef Moellers: "Re: how to write a program like top, whose output keep the line number constant"
- Next in thread: Basile Starynkevitch [news]: "Re: Is this an optimizer bug?"
- Reply: Basile Starynkevitch [news]: "Re: Is this an optimizer bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|