public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "m dot shulhan at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/38575]  New: free() accept argument that has the same name with standard/builtin function
Date: Fri, 19 Dec 2008 03:11:00 -0000	[thread overview]
Message-ID: <bug-38575-17097@http.gcc.gnu.org/bugzilla/> (raw)

Any variable that has the same name with standard/builtin function name will be
accepted by free parameter.

example of code,

>>>
#include <stdlib.h>
int main(int argc, char *argv[])
{
        free(rand);
        return 0;
}
<<<

This sample code will success on compile,

$ gcc -Wall -g -O0 free-bug.c

but error on run,

$ ./a.out

*** glibc detected *** ./a.out: free(): invalid pointer: 0x08048364 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7ee94b6]
/lib/libc.so.6(cfree+0x89)[0xb7eeb179]
./a.out[0x8048421]
/lib/libc.so.6(__libc_start_main+0xe0)[0xb7e98fe0]
./a.out[0x80483a1]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:03 7946378   
/home/rv77ax/doc/sandbox/c/a.out
08049000-0804a000 r--p 00000000 08:03 7946378   
/home/rv77ax/doc/sandbox/c/a.out
0804a000-0804b000 rw-p 00001000 08:03 7946378   
/home/rv77ax/doc/sandbox/c/a.out
0804b000-0806c000 rw-p 0804b000 00:00 0          [heap]
b7e76000-b7e80000 r-xp 00000000 08:01 817696     /lib/libgcc_s.so.1
b7e80000-b7e82000 rw-p 00009000 08:01 817696     /lib/libgcc_s.so.1
b7e82000-b7e83000 rw-p b7e82000 00:00 0
b7e83000-b7fb0000 r-xp 00000000 08:01 817612     /lib/libc-2.6.1.so
b7fb0000-b7fb1000 r--p 0012c000 08:01 817612     /lib/libc-2.6.1.so
b7fb1000-b7fb3000 rw-p 0012d000 08:01 817612     /lib/libc-2.6.1.so
b7fb3000-b7fb6000 rw-p b7fb3000 00:00 0
b7fcb000-b7fcc000 rw-p b7fcb000 00:00 0
b7fcc000-b7fe6000 r-xp 00000000 08:01 819693     /lib/ld-2.6.1.so
b7fe6000-b7fe8000 rw-p 0001a000 08:01 819693     /lib/ld-2.6.1.so
bfd0a000-bfd20000 rw-p bfd0a000 00:00 0          [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
Aborted


-- 
           Summary: free() accept argument that has the same name with
                    standard/builtin function
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: m dot shulhan at gmail dot com
 GCC build triplet: -Wall -g -O0
  GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux


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


             reply	other threads:[~2008-12-19  3:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-19  3:11 m dot shulhan at gmail dot com [this message]
2008-12-19  3:17 ` [Bug c/38575] " pinskia at gcc dot gnu dot org
2008-12-19  3:20 ` [Bug middle-end/38575] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-38575-17097@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).