From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by sourceware.org (Postfix) with ESMTPS id 682EB3858C39 for ; Fri, 17 Feb 2023 13:14:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 682EB3858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmx.at Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.at DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.at; s=s31663417; t=1676639678; i=hz2012@gmx.at; bh=HMIadXqD9g85fWl3qiD2n50+nhtsQ6WpqTyxC9CzSUw=; h=X-UI-Sender-Class:From:To:Subject:Date; b=r8LTOu2w/FkLN3EIn2dp0PcHygSB7Tiq38N2pqQQDAhqxaXW5+1XbOgSn+pZpMo8s tmnWGBF3+wfECr1z54wSWwJh1d14b2xl46tbFmGSJDgV6OHGNm9lT0HtHAWONEjd6j MUaWlU8mlLupaXYGibgjHFYdRPoF5/T631wuzdoJB8OFSuKTItsgZjz+thgRsIz1e/ xf8/DMXcBGppvLlkr8SJtwURSDEnTeUuOgNYcrd6VLMEZf7FEtOfO3jKqKWXN+a8+l QZJW2tnncrbylbi1Gp6rqlSGEXqg34HkQSuyu9sjS8vVO//6e0uJ94zKb4e4EQMCw1 /BXf8khGgShMw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [90.146.27.93] ([90.146.27.93]) by web-mail.gmx.net (3c-app-gmx-bs40.server.lan [172.19.170.92]) (via HTTP); Fri, 17 Feb 2023 14:14:38 +0100 MIME-Version: 1.0 Message-ID: From: Helmut Zeisel To: gcc@gcc.gnu.org Subject: Warning: shared mutable data Content-Type: text/plain; charset=UTF-8 Date: Fri, 17 Feb 2023 14:14:38 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:ixLQMFUMhYCWDQscNky8CzfKoBTyN4OZCjHDCR2+NMWPKqRtQZ38xmE5uN5KmI5K+DclI EcN9aahYL2FzkYdjehNlMxhb2B/0IQBnXfybvQ0tbuBLjIsggO0Kmf7wXJSUQJd2un21kDNqg2+/ SknwmfA+TM5V/cCx7r59mlMrJQ//+Lnu4tZXMCdS6j4Zo1fJBP8sIaFZW41iXQ4250CY7/YREk65 27bS/nDgRQnCqenTc6FWudKcsGreNvo+ArI7ae3bp6t0EP3H6mXC3Catq/44OCkwRpJdG45afLGA IE= UI-OutboundReport: notjunk:1;M01:P0:O/J1itHngu4=;xMry8bsUA8Lzfvran2BlDTinD74 ssI1pMXVpQVAqAuz1oDIw7R7uNPzoT2ABm8WTOJy3eUaj/azLUDFHum7yq59AzUE6FeV8jndW oxwDHZcrVr5UcjKC9q7YNJVl2bF9sQZ2q139juHr/wWECZOt5xZRrvDARZYrOq3ZUG9LpCdR+ Os9pEf9iudUNR8uGBmsa3hohYn1gyGDee/QmVqi1AymxcO1HfBWBTz1t7EP90JUGRyoKhKj5E o28fsFgCVdgxfRtszyS/L0wO411yXTNM6+g7LINFD6UWXbEMGsOeha+mjaetv70MfTC3CUKZW YojHsEZjUUxABqBHNiL+LF3shwo/rPJdRFXYuxcMZaUKWHB6X7vy5O8VSHGyq3zcrIZz8G+LO yaSZCBsc7VC7Ir7yPpB58ACScok1LmsFEjdZn4d4Y0VXkcfcIFcJK2cTMXKcPcROOIod6tLpF I66wmRjciQXyOGbKngDYPtYSw87EIdEYccBvYMMFL4oovcARwzSByAVAU3cpjb/YwlidLRiKF wYnwlFjnaDgqmWftztpn8bTH2XBkOwuter+RHluoyGh8LQQbJpnHlie32nVFeeaJ1km5OIknx qXEwADFAHPNZlDOghXwX+I5uPYdw1cNX94DCSB653fv84HwqdfD0sHcFMtF+BDKSNAqsZF/al QnnvKUx5dTIV1y5RAkxSQHXJN3RN7aeKMvQywznqMOIrEvsrBcORL03f0XSa7PNWM8338twAC egJ11TSyOciJMAaKI6qHZYGBb6xrJR0XMezzmGvfRix45VHy2a+ikUMeFBWy5j7YmtTuT7lmF /yVTtrxFp7CaedvzPXD63/Ww== Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 l= ike Val that forbids such code. =46rom 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? 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 bef= ore passing it to the function) .) Is it possible to find all such possbible errors when the complete prog= ram is compiled with this warning enabled? Even if it were not possible to detect all cases, also detecting some case= s might prevent some bugs. What do you think about adding a warning "shared mutable data" to GCC? Helmut Zeisel