Pelles C forum

Pelles C => Bug reports => Topic started by: jerome.hode on August 26, 2008, 03:39:10 PM

Title: compiler bug (infinite loop/allocation) when optimization!=none
Post by: jerome.hode on August 26, 2008, 03:39:10 PM
this code (extracted from libogg-1.1.3) sends POCC in a loop that exhausts memory when compiler's option "Optimizations" != none:

Code: [Select]
typedef unsigned long long ogg_int64_t;
typedef struct S_ogg_page {
unsigned char *header;
} ogg_page;

ogg_int64_t ogg_page_granulepos(ogg_page *og){
  unsigned char *page=og->header;
  ogg_int64_t granulepos=page[13]&(0xff);
  granulepos= (granulepos<<8)|(page[12]&0xff);
  granulepos= (granulepos<<8)|(page[11]&0xff);
  granulepos= (granulepos<<8)|(page[10]&0xff);
  granulepos= (granulepos<<8)|(page[9]&0xff);
  granulepos= (granulepos<<8)|(page[8]&0xff);
  granulepos= (granulepos<<8)|(page[7]&0xff);
  granulepos= (granulepos<<8)|(page[6]&0xff);
  return(granulepos);
}

About Pelles:
Pelles C for Windows
Version 5.00.8
RSRC0009.DLL: Version 5.00.1
SUPPORT.DLL: Version 5.00.2
POCFMT.DLL: Version 5.00.1
PORC.DLL: Version 5.00.1
POBR.DLL: Version 5.00.2
SQLITE3.DLL: Version 3.5.3
POCC.EXE: Version 5.00.13
POASM.EXE: Version 5.00.4
POLINK.EXE: Version 5.00.1
IDESPAWN.EXE: Version 5.00.1
MS Windows XP Pro, SP3 (Build 2600)
Title: Re: compiler bug (infinite loop/allocation) when optimization!=none
Post by: JohnF on August 27, 2008, 10:53:20 AM
I'm not able to reproduce that problem here.

John
Title: Re: compiler bug (infinite loop/allocation) when optimization!=none
Post by: Pelle on September 23, 2008, 06:04:11 PM
I can reproduce it. 64-bit integers doesn't really fit the limited x86 architecture. Yet another good reason to move on to x64.

I will look at it. You can obviously get around it by disabling optimizations (#pragma optimize etc.).