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 via email to