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/90404] No warning on attempts to modify a const object
Date: Mon, 12 Oct 2020 16:06:05 +0000	[thread overview]
Message-ID: <bug-90404-4-jHBj7oX0da@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-90404-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:3175d40fc52fb8eb3c3b18cc343d773da24434fb

commit r11-3829-g3175d40fc52fb8eb3c3b18cc343d773da24434fb
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Oct 7 18:34:09 2020 -0400

    analyzer: add warnings about writes to constant regions [PR95007]

    This patch adds two new warnings:
      -Wanalyzer-write-to-const
      -Wanalyzer-write-to-string-literal
    for code paths where the analyzer detects a write to a constant region.

    As noted in the documentation part of the patch, the analyzer doesn't
    prioritize detection of such writes, in that the state-merging logic
    will blithely lose the distinction between const and non-const regions.
    Hence false negatives are likely to arise due to state-merging.

    However, if the analyzer does happen to spot such a write, it seems worth
    reporting, hence this patch.

    gcc/analyzer/ChangeLog:
            * analyzer.opt (Wanalyzer-write-to-const): New.
            (Wanalyzer-write-to-string-literal): New.
            * region-model-impl-calls.cc (region_model::impl_call_memcpy):
            Call check_for_writable_region.
            (region_model::impl_call_memset): Likewise.
            (region_model::impl_call_strcpy): Likewise.
            * region-model.cc (class write_to_const_diagnostic): New.
            (class write_to_string_literal_diagnostic): New.
            (region_model::check_for_writable_region): New.
            (region_model::set_value): Call check_for_writable_region.
            * region-model.h (region_model::check_for_writable_region): New
            decl.

    gcc/ChangeLog:
            * doc/invoke.texi: Document -Wanalyzer-write-to-const and
            -Wanalyzer-write-to-string-literal.

    gcc/testsuite/ChangeLog:
            PR c/83347
            PR middle-end/90404
            PR analyzer/95007
            * gcc.dg/analyzer/write-to-const-1.c: New test.
            * gcc.dg/analyzer/write-to-string-literal-1.c: New test.

  parent reply	other threads:[~2020-10-12 16:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-90404-4@http.gcc.gnu.org/bugzilla/>
2020-03-16 16:54 ` msebor at gcc dot gnu.org
2020-03-16 19:04 ` msebor at gcc dot gnu.org
2020-03-24 21:59 ` msebor at gcc dot gnu.org
2020-10-12 16:06 ` cvs-commit at gcc dot gnu.org [this message]
2021-04-27 11:38 ` jakub at gcc dot gnu.org
2021-06-16 15:51 ` jamborm at gcc dot gnu.org
2021-07-28  7:04 ` rguenth at gcc dot gnu.org
2022-01-26 17:49 ` 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-90404-4-jHBj7oX0da@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).