[Bug c/13691] New: malloc returns eroneous pointer

janbor at fys dot uio dot no gcc-bugzilla@gcc.gnu.org
Wed Jan 14 23:55:00 GMT 2004


~>cat test.c
#include <stdio.h>
main()
{
  int n;
  double **A;
  for (n=8000;n<100000;n*=2) {
    A = (double **)malloc(n*sizeof(double *));
    printf("%d %d \n",n,A);
  }
}

~>gcc -o test test.c -lm
test.c: In function `main':
test.c:9: warning: cast to pointer from integer of different size
~>test 
8000 5301488
16000 5365504
32000 -1789435888
64000 -1789177840

-- 
           Summary: malloc returns eroneous pointer
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janbor at fys dot uio dot no
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13691



More information about the Gcc-bugs mailing list