Hi,

The following program compiles fine with all compilers I know of
(a.o., Apple's gcc4.0 and gcc4.2, GNU gcc4.3 ...), and fails with gcc4.4
(it comes from a saclib routine, after having used --save-temps
and some grepping to remove all macros and typedefs)  :

_____________________________
#include <stdlib.h>
extern int *MMAPMON (int m, int *A);
extern void MMAPREM (int m, int *A, int *B);

int *MMAPGCD(p,A,B)
      int p,*A,*B;
{
      int *A1,*A2,*t,*C,m,n;

      if (((A[-1]) == 0 && (A[0]) == 0)) {
  C = MMAPMON(p,B);
  goto Return; }
      if (((B[-1]) == 0 && (B[0]) == 0)) {
  C = MMAPMON(p,A);
  goto Return; }

      m = (A[-1]);
      n = (B[-1]);
      if (m >= n) {
  A1 = MMAPMON(p,A);
  A2 = MMAPMON(p,B); }
      else {
  A1 = MMAPMON(p,B);
  A2 = MMAPMON(p,A); }
      do {
  MMAPREM(p,A1,A2);
  t = A1;
  A1 = A2;
  A2 = t; }
      while (!((A2[-1]) == 0 && (A2[0]) == 0));
      C = MMAPMON(p,A1);

      free(((A1)-1));
      free(((A2)-1));

Return:
      return(C);
}
______________________________

# gcc-4 -c foo.c -O2 -Wall -Wextra -Wstrict-prototypes -Wstrict- aliasing=2 /Users/jfm/Desktop/saclib_fail.c:6: warning: function declaration isn't a prototype
cc1(72244) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

cc1: out of memory allocating 248 bytes after a total of 0 bytes
_______________________
with -O1 or -Os , no problem.
With gcc or gcc-4.2, or fink's gcc43 pkg, also no problem,
even with "-O3 -fstrict-aliasing"
_____________________________

JF Mertens

Reply via email to