Re: PING 4 [PATCH v2 2/2] add -Wdangling-pointer [PR #63272]
On 17/01/2022 20:14, Martin Sebor wrote: I tried to set up OpenOffice for testing with the latest GCC but couldn't get the build to finish (it failed downloading some unavailable prerequisites). I don't remember what problem I ran into with LibreOffice; it was before I upgraded to Fedora 35 just a couple of weeks ago. Let me retry again (the build is still downloading tarballs). In the meantime, do you have any tips or suggestions getting it set up that aren't on the instructions page below? (Especially for using an alternate compiler and non-default options.) https://wiki.documentfoundation.org/Development/BuildingOnLinux#Fedora.2FRedHat Building LibreOffice from source should be relatively easy these days, esp. on Linux. Let me know if you have any specific issues. What I do to build against a GCC other than the system one is to include the two lines CC=/path/to/gcc CXX=/path/to/g++ in autogen.input. (And if you have any issues building LibreOffice, I guess you would have an even worse experience trying to build OpenOffice. I for one never looked back.)
Re: PING 4 [PATCH v2 2/2] add -Wdangling-pointer [PR #63272]
On 1/17/22 06:46, Stephan Bergmann wrote: On 10/01/2022 22:51, Martin Sebor via Gcc-patches wrote: Last ping for this stage 1 feature before stage 3 ends: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html This hits somewhat unexpectedly at (test case reduced from a hit in LibreOffice) Thanks for the small test case! It seems like the PHI handling (conditionals) might overly simplistic. Let me look into it. I tried to set up OpenOffice for testing with the latest GCC but couldn't get the build to finish (it failed downloading some unavailable prerequisites). I don't remember what problem I ran into with LibreOffice; it was before I upgraded to Fedora 35 just a couple of weeks ago. Let me retry again (the build is still downloading tarballs). In the meantime, do you have any tips or suggestions getting it set up that aren't on the instructions page below? (Especially for using an alternate compiler and non-default options.) https://wiki.documentfoundation.org/Development/BuildingOnLinux#Fedora.2FRedHat Martin $ cat test.cc #include struct S1 { S1(int); ~S1(); }; struct S2 { S2(std::initializer_list); }; S2 f1(); S2 f2(bool b) { return b ? f1() : S2{0}; } $ g++ -Wdangling-pointer -c test.cc test.cc: In function ‘S2 f2(bool)’: test.cc:8:42: warning: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=] 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^ test.cc:8:39: note: unnamed temporary defined here 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^ test.cc:8:42: warning: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=] 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^ test.cc:8:39: note: unnamed temporary defined here 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^
Re: PING 4 [PATCH v2 2/2] add -Wdangling-pointer [PR #63272]
On 10/01/2022 22:51, Martin Sebor via Gcc-patches wrote: Last ping for this stage 1 feature before stage 3 ends: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html This hits somewhat unexpectedly at (test case reduced from a hit in LibreOffice) $ cat test.cc #include struct S1 { S1(int); ~S1(); }; struct S2 { S2(std::initializer_list); }; S2 f1(); S2 f2(bool b) { return b ? f1() : S2{0}; } $ g++ -Wdangling-pointer -c test.cc test.cc: In function ‘S2 f2(bool)’: test.cc:8:42: warning: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=] 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^ test.cc:8:39: note: unnamed temporary defined here 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^ test.cc:8:42: warning: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=] 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^ test.cc:8:39: note: unnamed temporary defined here 8 | S2 f2(bool b) { return b ? f1() : S2{0}; } | ^
PING 4 [PATCH v2 2/2] add -Wdangling-pointer [PR #63272]
Last ping for this stage 1 feature before stage 3 ends: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html On 1/4/22 11:02, Martin Sebor wrote: Ping: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html On 12/13/21 9:50 AM, Martin Sebor wrote: Ping. This patch, originally submitted on Nov. 1, has not been reviewed yet. https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html On 12/6/21 5:51 PM, Martin Sebor wrote: Ping: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585819.html On 11/30/21 3:55 PM, Martin Sebor wrote: Attached is a revision of this patch with adjustments for the changes to the prerequisite patch 1 in the series and a couple of minor simplifications and slightly improved test coverage, rested on x86_64-linux. On 11/1/21 4:18 PM, Martin Sebor wrote: Patch 2 in this series adds support for detecting the uses of dangling pointers: those to auto objects that have gone out of scope. Like patch 1, to minimize false positives this detection is very simplistic. However, thanks to the more deterministic nature of the problem (all local objects go out of scope) is able to detect more instances of it. The approach I used is to simply search the IL for clobbers that dominate uses of pointers to the clobbered objects. If such a use is found that's not followed by a clobber of the same object the warning triggers. Similar to -Wuse-after-free, the new -Wdangling-pointer option has multiple levels: level 1 to detect unconditional uses and level 2 to flag conditional ones. Unlike with -Wuse-after-free there is no use case for testing dangling pointers for equality, so there is no level 3. Tested on x86_64-linux and by building Glibc and Binutils/GDB. It found no problems outside of the GCC test suite. As with the first patch in this series, the tests contain a number of xfails due to known limitations marked with pr??. I'll open bugs for them before committing the patch if I don't resolve them first in a followup. Martin