Dear gcc guru,
I'm using gcc 2.95.3 on a 2.4 GHz Xeon with 4GB of ram running redhat linux with the 2.4.20 and/or 2.4.27 kernel. For the project I'm working on, I have no choice but to use 2.95.3.
If I create a large structure, then create a pointer to that structure, then use the pointer to reference areas of the structure more than 0xfffffff bytes from the beginning of the structure, I get a seg fault.
In the attached sample code, the "got here 3" prints, but the "got here 4" does not. The line of code between those lines produces the seg fault.
I know the memory for the structure is getting allocated, and calloc never fails, so the allocated memory can be written.
Based on what I've seen, I would guess that whatever assembly language addressing mode is being used has an offset limit of 0xfffffff.
I look forward to any help you may be able to provide.
Thank you very much,
Mark
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int begin;
int middle[100000000];
int end;
} big_str;
void main (void)
{
big_str *bp;
bp = calloc (sizeof(big_str));
if (bp == NULL)
{
printf ("malloc failed \n");
exit (1);
}
printf ("got here 1 \n");
bp->begin = 1;
printf ("got here 2 \n");
bp->middle[0] = 1;
printf ("got here 3 \n");
bp->middle[67108862] = 1;
printf ("got here 4 \n");
bp->middle[67108863] = 1;
printf ("got here 5 \n");
bp->end = 1;
printf ("got here 6 \n");
} /* end main */
_______________________________________________ Help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
