On Fri, 07 Nov 2003 12:36:43 +0000, John wrote:
> I'm getting a segmentation fault when I try to realloc memory.
>
> This only happens when I compile using gcc v. 3.2 on Red Hat Linux 8.0
> 3.2-7. When I compile on Solaris 5.7 using gcc v. 2.95.2, the error
> does not occur.
>
> Is there a way to solve this using compiler options, or any other
> method? In the end, I need this program to compile on the Linux box.
>
> Any help would be greatly appreciated!!!
> Thanks.
The way your question is written, you almost make it sound like the
compiler is segfaulting.
But I gather that it is your compiled executable, not the compiler. The
most likely explanation is that you have a bug in your code. The only
compiler flags which are likely to help are the ones which perform checks
on your code to warn against possible bugs. (e.g., -Wall -pedantic)
If you can simplify the code to the smallest example which still exhibits
the segfault, making sure in the process to remove any platform dependent
stuff which would make it fail to compile on other platforms, then you can
post the code here and I am sure someone will find the problem.
If you do this, make sure you cut and paste the program, otherwise all the
feedback you get will probably be over a typo.
Mac
--