Problem with GCC under MacOSX

Pierre Chatelier ktd@club-internet.fr
Sat Nov 16 08:53:00 GMT 2002


Hello,
I'm really disappointed with the built-in gcc under MacOS X. (gcc 3.1)

I encountered a severe problem while re-compiling a simple C application
that I usually run under Linux on PC.
The program crashes when calling a function like the one below :
void foo(void)
{
  char buffer[512][1024];
  /*some code...*/
}

I only get a segmentation fault (without any core dump). I think it is
due to the array, that the stack may find too wide, because if I replace
the "auto-allocation" of the buffer by a dynamic allocation (with
malloc()), it works well; but it's far from what I want.
The initial program works perfecly under Linux on my PC. Why not with
Darwin? Does it come from gcc? from darwin? from the couple gcc/darwin?
from MacOSX?

And how strange, the day before I encountered this problem, I was by a
friend who was cross-compiling an application and could not make it
work, because of a strange segmentation fault. The problem was exactly
the same as mine : a function was using an array, which size was about
73000 char, if I remember well. He used a malloc() and it worked. The
code he tried to compile was coming from a VisualC++ project,and was
working well under Windows.
So we are at least two people who have independantly encountered this
problem within two days.

Even if we have the solution to use malloc() instead of the
auto-allocation, I think it is bad, because it reflects a real weakness
with the Jaguar-gcc. A simple program which works under Linux should
work under another Unix without modifying the code!

Is it a known bug? Is there a solution with some PPC compiler flags?
Will it be fixed soon?

In fact, while I am not sure that gcc is guilty, I will also send this
mail to the MacOSX feedback.

Regards,
Pierre Chatelier



More information about the Gcc-help mailing list