This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: free (static_array)


On Tuesday 01 July 2008 08:38, Sajish V wrote:
> Hi All, 
> Can you please let me know why GCC does not crib when we try to free a static array?
> main ()
> { 
> ???? char array[100];
> ???? free (array);
> }
> The above code compiles without any hitch. 
> Thanks,
> Sajish.

# ./a.out
*** glibc detected *** ./a.out: free(): invalid pointer: 0xffa8b530 ***
======= Backtrace: =========
/lib/libc.so.6[0xf7ecb7a7]
/lib/libc.so.6(__libc_free+0x79)[0xf7ecc0ad]
./a.out[0x804834e]
/lib/libc.so.6(__libc_start_main+0x138)[0xf7e8da74]
./a.out[0x80482b5]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:06 1315925                            /.local/tmp/a.out
08049000-0804a000 rwxp 00000000 08:06 1315925                            /.local/tmp/a.out
0804a000-0806b000 rwxp 0804a000 00:00 0                                  [heap]
f7e6f000-f7e76000 r-xp 00000000 08:05 46193                              /app/gcc-3.3.3/lib/libgcc_s.so.1
f7e76000-f7e77000 rwxp 00006000 08:05 46193                              /app/gcc-3.3.3/lib/libgcc_s.so.1
f7e77000-f7e78000 rwxp f7e77000 00:00 0
f7e78000-f7f60000 r-xp 00000000 08:0

--
vda


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]