public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Helmut Zeisel <HZ2012@gmx.at>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Warning: shared mutable data
Date: Fri, 17 Feb 2023 14:06:19 +0000	[thread overview]
Message-ID: <CAH6eHdQP4CHPcsfLT1=szPMvrdNrUqiDzVskXyHi0RCo-bJtJw@mail.gmail.com> (raw)
In-Reply-To: <trinity-2c1fcb45-a1d8-415f-b03f-ac35a7d54b9b-1676639678378@3c-app-gmx-bs40>

[-- Attachment #1: Type: text/plain, Size: 1468 bytes --]

On Fri, 17 Feb 2023, 13:15 Helmut Zeisel via Gcc, <gcc@gcc.gnu.org> wrote:

> Recently I read about Value-Oriented Programming
> ( https://accu.org/journals/overload/31/173/teodorescu/ )
> There it is pointed out that sharing mutable data. i. e., code like
>
> my_push_back(vec, vec[0]);
>
> can lead to subtle errors. Of course GCC cannot change C++ to a language
> like Val that forbids such code.
> From my understanding, however, sharing of mutable data can be detected by
> the compiler on caller side
> (looking at the prototype of the function - are all shared arguments const
> or is there some mutable argument?)
> and it might be possible to add a warning "shared mutable data".
>
> How difficult is it to implement such a warning?
>

What exactly are you suggesting for the semantics of the warning? You
haven't described what you want it to do, for anybody to say how difficult
it would be.



> If we have such a warning, it will be possible to get some information
>
> .) How often such code occurs in real programs?
> .) Is it difficult to fix such code (e.g. by making a copy of the data
> before passing it to the function)
> .) Is it possible to find all such possbible errors when the complete
> program is compiled with this warning enabled?
>
> Even if it were not possible to detect all cases, also detecting some
> cases might prevent some bugs.
>
> What do you think about adding a warning "shared mutable data" to GCC?
>
> Helmut Zeisel
>
>
>

  reply	other threads:[~2023-02-17 14:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17 13:14 Helmut Zeisel
2023-02-17 14:06 ` Jonathan Wakely [this message]
2023-02-17 15:57   ` Aw: " Helmut Zeisel

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='CAH6eHdQP4CHPcsfLT1=szPMvrdNrUqiDzVskXyHi0RCo-bJtJw@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=HZ2012@gmx.at \
    --cc=gcc@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).