public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95485] New: missing warning writing into function text Date: Tue, 02 Jun 2020 20:14:42 +0000 [thread overview] Message-ID: <bug-95485-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95485 Bug ID: 95485 Summary: missing warning writing into function text Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC doesn't diagnose attempts to write into functions, even though those will in all likelihood crash with a SIGBUS at runtime. For example, in the following snippet the destination of the memset call is a function rather than the memory it was called to obtain. The memset call should be diagnosed. $ cat z.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout z.c typedef void* F (int); void* f (F *p) { void *q = p (32); // allocate memory __builtin_memset (p, 0, 32); // zero out -- whoops! -- writing to a function return q; // return "clear" memory } ;; Function f (f, funcdef_no=0, decl_uid=1933, cgraph_uid=1, symbol_order=0) f (void * (*<T322>) (int) p) { void * q; <bb 2> [local count: 1073741824]: q_4 = p_2(D) (32); __builtin_memset (p_2(D), 0, 32); return q_4; } Two compilers on Godbolt diagnose the code: Visual C++: z.c(8): warning C4152: nonstandard extension, function/data pointer conversion in expression and the Small Device C Compiler (SDCC): x.c:8: warning 244: pointer types incompatible from type 'void generic* function ( int fixed) code* fixed' to type 'void generic* fixed'
next reply other threads:[~2020-06-02 20:14 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-02 20:14 msebor at gcc dot gnu.org [this message] 2020-06-02 20:15 ` [Bug middle-end/95485] " msebor at gcc dot gnu.org 2020-06-02 20:21 ` msebor at gcc dot gnu.org 2020-06-03 5:05 ` egallager at gcc dot gnu.org 2020-06-03 16:23 ` msebor at gcc dot gnu.org 2022-01-04 6:51 ` egallager at gcc dot gnu.org 2022-01-26 17:55 ` msebor at gcc dot gnu.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-95485-4@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: linkBe 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).