public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hubicka at ucw dot cz" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/63459] operator new and returns_nonnull Date: Wed, 08 Oct 2014 17:59:00 -0000 [thread overview] Message-ID: <bug-63459-4-0g5pzrjzaz@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-63459-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63459 --- Comment #5 from Jan Hubicka <hubicka at ucw dot cz> --- Hi, does something like this make sense (I also updated the DECL_BY_REFERENCE check. We allow to put variable at address NULL with -fno-delete-null-pointer-checks that IMO can let me to pass it by reference. Why this is not part of tree_expr_nonzero_p and vrp is not simply calling it to set up the value ranges? Honza Index: tree-vrp.c =================================================================== --- tree-vrp.c (revision 215901) +++ tree-vrp.c (working copy) @@ -365,6 +365,18 @@ nonnull_arg_p (const_tree arg) if (arg == cfun->static_chain_decl) return true; + /* THIS argument of method is always non-NULL. */ + if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE + && arg == DECL_ARGUMENTS (current_function_decl)) + return true; + + /* Parameters passed by invisible reference are also always non-NULL + unsless we explicitly allow symbol to have NULL address, that is + permitted by -fno-delete-null-pointer-checks. */ + if (DECL_BY_REFERENCE (arg) + && flag_delete_null_pointer_checks) + return true; + fntype = TREE_TYPE (current_function_decl); for (attrs = TYPE_ATTRIBUTES (fntype); attrs; attrs = TREE_CHAIN (attrs)) { @@ -772,7 +784,8 @@ get_value_range (const_tree var) set_value_range_to_varying (vr); } else if (TREE_CODE (sym) == RESULT_DECL - && DECL_BY_REFERENCE (sym)) + && DECL_BY_REFERENCE (sym) + && flag_delete_null_pointer_checks) set_value_range_to_nonnull (vr, TREE_TYPE (sym)); }
next prev parent reply other threads:[~2014-10-08 17:59 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-10-04 19:24 [Bug c++/63459] New: " hubicka at gcc dot gnu.org 2014-10-04 20:27 ` [Bug c++/63459] " glisse at gcc dot gnu.org 2014-10-04 20:54 ` hubicka at gcc dot gnu.org 2014-10-04 21:12 ` glisse at gcc dot gnu.org 2014-10-06 14:50 ` rguenth at gcc dot gnu.org 2014-10-08 17:59 ` hubicka at ucw dot cz [this message] 2014-10-08 18:19 ` hubicka at ucw dot cz 2014-11-29 19:34 ` glisse 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-63459-4-0g5pzrjzaz@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).