[Bug c/87387] trunk/gcc/builtins.c:585:7: warning: -Wself-assign problem
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 --- Comment #1 from David Binderman --- I found this bug by compiling gcc with the new clang 7.0 It seems that gcc can't be encouraged to warn about self-assignment. For example: $cat sep23a.cc // -Wself-assign. clang has it. gcc doesn't. extern void g( int); void f(int n) { int m = 2 * n; m = m; g( m); } $ ~/gcc/results/bin/gcc -c -O2 -Wall -Wextra sep23a.cc $ Given that this warning finds bugs in gcc itself, would this -Wself-assign warning be worth implementing in gcc ? I'll have a go at compiling the rest of the world with clang-7.0 and see what it finds.
[Bug c/87387] trunk/gcc/builtins.c:585:7: warning: -Wself-assign problem
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 --- Comment #2 from David Binderman --- Looks like an old implementation: https://gcc.gnu.org/ml/gcc-patches/2010-06/msg02390.html It might be worth using this as a starting point.
[Bug c/87387] trunk/gcc/builtins.c:585:7: warning: -Wself-assign problem
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 Eric Gallager changed: What|Removed |Added CC||egallager at gcc dot gnu.org See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=53129 --- Comment #3 from Eric Gallager --- (In reply to David Binderman from comment #1) > I found this bug by compiling gcc with the new clang 7.0 > > It seems that gcc can't be encouraged to warn about self-assignment. > > For example: > > $cat sep23a.cc > // -Wself-assign. clang has it. gcc doesn't. > > extern void g( int); > > void f(int n) > { > int m = 2 * n; > > m = m; > > g( m); > } > > $ ~/gcc/results/bin/gcc -c -O2 -Wall -Wextra sep23a.cc > $ > > Given that this warning finds bugs in gcc itself, would this > -Wself-assign warning be worth implementing in gcc ? That's bug 53129. > > I'll have a go at compiling the rest of the world with clang-7.0 > and see what it finds.
[Bug c/87387] trunk/gcc/builtins.c:585:7: warning: -Wself-assign problem
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 --- Comment #4 from Jeffrey A. Law --- Author: law Date: Tue Sep 25 22:17:45 2018 New Revision: 264585 URL: https://gcc.gnu.org/viewcvs?rev=264585&root=gcc&view=rev Log: PR c/87387 * builtins.c (unterminated_array): Simplify. * expr.c (string_constant): Handle SSA_NAME. Add more exceptions where pointer arithmetic is safe. * gcc.dg/warn-stpcpy-no-nul.c: Drop unnecessary xfails. * gcc.dg/warn-stplen-no-nul.c: Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/builtins.c trunk/gcc/expr.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/warn-stpcpy-no-nul.c trunk/gcc/testsuite/gcc.dg/warn-strlen-no-nul.c
[Bug c/87387] trunk/gcc/builtins.c:585:7: warning: -Wself-assign problem
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 Jeffrey A. Law changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #5 from Jeffrey A. Law --- Fixed on the trunk.
[Bug c/87387] trunk/gcc/builtins.c:585:7: warning: -Wself-assign problem
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87387 --- Comment #6 from jamespharvey20 at gmail dot com --- This fix introduces bug 87672.