bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

x86_64: malloc returns erroneous pointer with large argument


From: Bording, Jan
Subject: x86_64: malloc returns erroneous pointer with large argument
Date: Wed, 14 Jan 2004 19:50:21 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313

This error is for x86_64 only !!
If I remove the line 12: "B[3] = ..." I get the same warnings, but the code runs. Line 12 produces a segmentation fault because
B is negative... (A is positive). Both A and B are positive
on a i386.

Jan K. Bording


~>cat test.c
#include <stdio.h>

main()
{
 int n;
 double **A,**B;

 A = (double **)malloc(16000*sizeof(double *));
 B = (double **)malloc(32000*sizeof(double *));

 A[3] = (double *)malloc(1*sizeof(double));
 B[3] = (double *)malloc(1*sizeof(double));
}

~> gcc -o test test.c -lm
test.c: In function `main':
test.c:8: warning: cast to pointer from integer of different size
test.c:9: warning: cast to pointer from integer of different size
test.c:11: warning: cast to pointer from integer of different size
test.c:12: warning: cast to pointer from integer of different size

~>test
Segmentation fault (core dumped)







reply via email to

[Prev in Thread] Current Thread [Next in Thread]