public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/63272] GCC should warn when using pointer to dead scoped variable within the same function
Date: Sat, 15 Jan 2022 23:46:33 +0000	[thread overview]
Message-ID: <bug-63272-4-hos5K31BQ8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-63272-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63272

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:9d6a0f388eb048f8d87f47af78f07b5ce513bfe6

commit r12-6606-g9d6a0f388eb048f8d87f47af78f07b5ce513bfe6
Author: Martin Sebor <msebor@redhat.com>
Date:   Sat Jan 15 16:41:40 2022 -0700

    Add -Wdangling-pointer [PR63272].

    Resolves:
    PR c/63272 - GCC should warn when using pointer to dead scoped variable
with
    in the same function

    gcc/c-family/ChangeLog:

            PR c/63272
            * c.opt (-Wdangling-pointer): New option.

    gcc/ChangeLog:

            PR c/63272
            * diagnostic-spec.c (nowarn_spec_t::nowarn_spec_t): Handle
            -Wdangling-pointer.
            * doc/invoke.texi (-Wdangling-pointer): Document new option.
            * gimple-ssa-warn-access.cc (pass_waccess::clone): Set new member.
            (pass_waccess::check_pointer_uses): New function.
            (pass_waccess::gimple_call_return_arg): New function.
            (pass_waccess::gimple_call_return_arg_ref): New function.
            (pass_waccess::check_call_dangling): New function.
            (pass_waccess::check_dangling_uses): New function overloads.
            (pass_waccess::check_dangling_stores): New function.
            (pass_waccess::check_dangling_stores): New function.
            (pass_waccess::m_clobbers): New data member.
            (pass_waccess::m_func): New data member.
            (pass_waccess::m_run_number): New data member.
            (pass_waccess::m_check_dangling_p): New data member.
            (pass_waccess::check_alloca): Check m_early_checks_p.
            (pass_waccess::check_alloc_size_call): Same.
            (pass_waccess::check_strcat): Same.
            (pass_waccess::check_strncat): Same.
            (pass_waccess::check_stxcpy): Same.
            (pass_waccess::check_stxncpy): Same.
            (pass_waccess::check_strncmp): Same.
            (pass_waccess::check_memop_access): Same.
            (pass_waccess::check_read_access): Same.
            (pass_waccess::check_builtin): Call check_pointer_uses.
            (pass_waccess::warn_invalid_pointer): Add arguments.
            (is_auto_decl): New function.
            (pass_waccess::check_stmt): New function.
            (pass_waccess::check_block): Call check_stmt.
            (pass_waccess::execute): Call check_dangling_uses,
            check_dangling_stores.  Empty m_clobbers.
            * passes.def (pass_warn_access): Invoke pass two more times.

    gcc/testsuite/ChangeLog:

            PR c/63272
            * g++.dg/warn/Wfree-nonheap-object-6.C: Disable valid warnings.
            * g++.dg/warn/ref-temp1.C: Prune expected warning.
            * gcc.dg/uninit-pr50476.c: Expect a new warning.
            * c-c++-common/Wdangling-pointer-2.c: New test.
            * c-c++-common/Wdangling-pointer-3.c: New test.
            * c-c++-common/Wdangling-pointer-4.c: New test.
            * c-c++-common/Wdangling-pointer-5.c: New test.
            * c-c++-common/Wdangling-pointer-6.c: New test.
            * c-c++-common/Wdangling-pointer.c: New test.
            * g++.dg/warn/Wdangling-pointer-2.C: New test.
            * g++.dg/warn/Wdangling-pointer.C: New test.
            * gcc.dg/Wdangling-pointer-2.c: New test.
            * gcc.dg/Wdangling-pointer.c: New test.

  parent reply	other threads:[~2022-01-15 23:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 22:31 [Bug c/63272] New: " jacob.benoit.1 at gmail dot com
2014-09-16  6:14 ` [Bug c/63272] " manu at gcc dot gnu.org
2020-10-30 10:06 ` dcb314 at hotmail dot com
2021-11-01 22:21 ` msebor at gcc dot gnu.org
2021-12-16 23:31 ` msebor at gcc dot gnu.org
2021-12-17  9:06 ` [Bug middle-end/63272] " dcb314 at hotmail dot com
2022-01-15 23:46 ` cvs-commit at gcc dot gnu.org [this message]
2022-01-16  0:04 ` msebor at gcc dot gnu.org
2024-04-09  7:32 ` pinskia at gcc dot gnu.org
2024-04-09  7:33 ` pinskia 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-63272-4-hos5K31BQ8@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).