[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2021-07-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Andrew Pinski  changed:

   What|Removed |Added

 CC||ldionne.2 at gmail dot com

--- Comment #7 from Andrew Pinski  ---
*** Bug 82000 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-19 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Martin Sebor  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Martin Sebor  ---
Patch committed in r269814.

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-19 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

--- Comment #5 from Martin Sebor  ---
Author: msebor
Date: Tue Mar 19 22:43:10 2019
New Revision: 269814

URL: https://gcc.gnu.org/viewcvs?rev=269814=gcc=rev
Log:
PR tree-optimization/89688 - -Wstringop-overflow confused by const 2D array of
char

gcc/c/ChangeLog:

PR tree-optimization/89688
* c-decl.c (finish_decl): Call braced_lists_to_string for more
kinds of initializers.

gcc/c-family/ChangeLog:

PR tree-optimization/89688
* c-common.c (braced_list_to_string): Make static.
(braced_lists_to_strings): Define new function.
* c-common.h (braced_list_to_string): Remove.
(braced_lists_to_strings): Declare.

gcc/cp/ChangeLog:

PR tree-optimization/89688
* typeck2.c (store_init_value): Call braced_lists_to_string for more
kinds of initializers.

gcc/testsuite/ChangeLog:

PR tree-optimization/89688
* gcc.dg/strlenopt-61.c: New test.
* g++.dg/warn/Wstringop-overflow-2.C: New test.


Added:
trunk/gcc/testsuite/g++.dg/warn/Wstringop-overflow-2.C
trunk/gcc/testsuite/gcc.dg/strlenopt-61.c
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c-family/c-common.h
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-decl.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/typeck2.c
trunk/gcc/testsuite/ChangeLog

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-13 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=86708
 Depends on|86708   |

--- Comment #4 from Martin Sebor  ---
Patch: https://gcc.gnu.org/ml/gcc-patches/2019-03/msg00677.html

Turns out pr86708 is not quite the same.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86708
[Bug 86708] strlen of an empty aggregate element or member string not folded

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-13 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1
   Target Milestone|--- |9.0

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-12 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Martin Sebor  changed:

   What|Removed |Added

 Depends on||86708

--- Comment #3 from Martin Sebor  ---
The missing optimization is the subject of pr86708.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86708
[Bug 86708] strlen of an empty aggregate element or member string not folded

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-12 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Martin Sebor  changed:

   What|Removed |Added

 Blocks||83819

--- Comment #2 from Martin Sebor  ---
Actually, it's slightly more complicated.  string_constant does fold the
reference to the STRING_CST "2" but with the size of 1 because it doesn't
consider the implicit zero that follows the '2'.  Simply changing
string_constant to look at the next element to see if it's zero isn't enough to
handle the case when the zero is implicit because fold_ctor_reference called to
extract the element value only handles explicit initializers.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83819
[Bug 83819] [meta-bug] missing strlen optimizations

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-12 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org

[Bug tree-optimization/89688] [9 Regression] -Wstringop-overflow confused by const 2D array of char

2019-03-12 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89688

Martin Sebor  changed:

   What|Removed |Added

   Keywords||diagnostic,
   ||missed-optimization
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-03-12
 CC||msebor at gcc dot gnu.org
  Component|c++ |tree-optimization
Summary|-Wstringop-overflow |[9 Regression]
   |confused by 2D array of |-Wstringop-overflow
   |char|confused by const 2D array
   ||of char
 Ever confirmed|0   |1

--- Comment #1 from Martin Sebor  ---
Confirmed.  string_constant successfully folds the call but also sets *DECL to
point to the array which fold_builtin_strlen interprets as the array not being
nul-terminated.  This in turn disables the folding and results in the false
positive.  Fixing it should be as simple as clearing *DECL.

The false positive is a regression.  The strlen() call wasn't folded before so
it by itself isn't, but they might both as well be fixed together.