public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/94226] New: [10 regression] r10-7272 eliminated some warning messages
@ 2020-03-19 18:05 seurer at linux dot vnet.ibm.com
  2020-03-19 18:44 ` [Bug middle-end/94226] " msebor at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: seurer at linux dot vnet.ibm.com @ 2020-03-19 18:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94226

            Bug ID: 94226
           Summary: [10 regression] r10-7272 eliminated some warning
                    messages
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: seurer at linux dot vnet.ibm.com
  Target Milestone: ---

git g:73bc09fa8c6b973a928a599498caa66a25c8bc8d, r10-7272

Executing on host: /home/seurer/gcc/git/build/gcc-test2/gcc/xgcc
-B/home/seurer/gcc/git/build/gcc-test2/gcc/
/home/seurer/gcc/git/gcc-test2/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-23.c
   -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers
-fdiagnostics-color=never  -fdiagnostics-urls=never   -O2 -Wno-format-overflow
-Wrestrict -ftrack-macro-expansion=0 -S -o builtin-sprintf-warn-23.s   
(timeout = 300)
spawn -ignore SIGHUP /home/seurer/gcc/git/build/gcc-test2/gcc/xgcc
-B/home/seurer/gcc/git/build/gcc-test2/gcc/
/home/seurer/gcc/git/gcc-test2/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-23.c
-fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers
-fdiagnostics-color=never -fdiagnostics-urls=never -O2 -Wno-format-overflow
-Wrestrict -ftrack-macro-expansion=0 -S -o builtin-sprintf-warn-23.s
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-23.c  (test for warnings, line 164)
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-23.c  (test for warnings, line 165)
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-23.c  (test for warnings, line 174)
FAIL: gcc.dg/tree-ssa/builtin-sprintf-warn-23.c  (test for warnings, line 175)

It looks like the warnings that used to be generated for the above no longer
are.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/94226] [10 regression] r10-7272 eliminated some warning messages
  2020-03-19 18:05 [Bug other/94226] New: [10 regression] r10-7272 eliminated some warning messages seurer at linux dot vnet.ibm.com
@ 2020-03-19 18:44 ` msebor at gcc dot gnu.org
  2020-03-20  7:27 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-03-19 18:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94226

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |84774
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |msebor at gcc dot gnu.org
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2020-03-19

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
$ cat pr94226.c && gcc -O2 -S -Wall -fdump-tree-strlen=/dev/stdout pr94226.c
extern char a2[2][22];

int f (void)
{
  return __builtin_sprintf (a2[1], "%s", a2[1] + 1);   // expect -Wrestrict
}


;; Function f (f, funcdef_no=0, decl_uid=1931, cgraph_uid=1, symbol_order=0)

;; 1 loops found
;;
;; Loop 0
;;  header 0, latch 1
;;  depth 0, outer -1
;;  nodes: 0 1 2
;; 2 succs { 1 }
pr94226.c:5: __builtin_sprintf: objsize = 22, fmtstr = "%s"
  Directive 1 at offset 0: "%s"
    Result: 0, 20, 20, 20 (0, 20, 20, 20)
  Directive 2 at offset 2: "", length = 1
  Setting in-bounds return value range [0, 20].

f ()
{
  int _3;

  <bb 2> [local count: 1073741824]:
  _3 = __builtin_sprintf (&a2[1], "%s", &MEM <char[22]> [(void *)&a2 + 23B]);
  return _3;

}


Prior to the change GCC issued the warning below:

a.c: In function ‘f’:
a.c:7:10: warning: ‘__builtin_sprintf’ argument 3 may overlap destination
object ‘a2’ [-Wrestrict]
    7 |   return __builtin_sprintf (a2[1], "%s", a2[1] + 1);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.c:3:13: note: destination object referenced by ‘restrict’-qualified argument
1 was declared here
    3 | extern char a2[2][22];
      |             ^~

The warning code in gimple-ssa-sprintf.c most likely needs adjusting.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84774
[Bug 84774] [meta-bug] bogus/missing -Wrestrict

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/94226] [10 regression] r10-7272 eliminated some warning messages
  2020-03-19 18:05 [Bug other/94226] New: [10 regression] r10-7272 eliminated some warning messages seurer at linux dot vnet.ibm.com
  2020-03-19 18:44 ` [Bug middle-end/94226] " msebor at gcc dot gnu.org
@ 2020-03-20  7:27 ` rguenth at gcc dot gnu.org
  2020-03-20  7:43 ` rguenth at gcc dot gnu.org
  2020-03-20  9:53 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-20  7:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94226

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.0
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/94226] [10 regression] r10-7272 eliminated some warning messages
  2020-03-19 18:05 [Bug other/94226] New: [10 regression] r10-7272 eliminated some warning messages seurer at linux dot vnet.ibm.com
  2020-03-19 18:44 ` [Bug middle-end/94226] " msebor at gcc dot gnu.org
  2020-03-20  7:27 ` rguenth at gcc dot gnu.org
@ 2020-03-20  7:43 ` rguenth at gcc dot gnu.org
  2020-03-20  9:53 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-20  7:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94226

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is most likely get_origin_and_offset which looks at the pointer
argument pointed-to-type:

          tree xtype = TREE_TYPE (TREE_TYPE (x));

          /* The byte offset of the most basic struct member the byte
             offset *OFF corresponds to, or for a (multidimensional)
             array member, the byte offset of the array element.  */
          HOST_WIDE_INT index = 0;

          if ((RECORD_OR_UNION_TYPE_P (xtype)
               && field_at_offset (xtype, *off, &index))
              || (TREE_CODE (xtype) == ARRAY_TYPE
                  && TREE_CODE (TREE_TYPE (xtype)) == ARRAY_TYPE
                  && array_elt_at_offset (xtype, *off, &index)))
            {
              *fldoff += index;
              *off -= index;
            }

here we now see a single-dimensional array because the MEM[&MEM] propagation
simply preserves the original pointer type.  Since the pointer type doesn't
have any semantics heuristics should better look at the type of the underlying
object (if there is any).

The following fixes this testcase (not that I agree with the way all this
is written):

diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 13640e0fd36..1879686ce0a 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -2331,7 +2331,9 @@ get_origin_and_offset (tree x, HOST_WIDE_INT *fldoff,
HOST_WIDE_INT *off)

       if (off)
        {
-         tree xtype = TREE_TYPE (TREE_TYPE (x));
+         tree xtype
+           = (TREE_CODE (x) == ADDR_EXPR
+              ? TREE_TYPE (TREE_OPERAND (x, 0)) : TREE_TYPE (TREE_TYPE (x)));

          /* The byte offset of the most basic struct member the byte
             offset *OFF corresponds to, or for a (multidimensional)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/94226] [10 regression] r10-7272 eliminated some warning messages
  2020-03-19 18:05 [Bug other/94226] New: [10 regression] r10-7272 eliminated some warning messages seurer at linux dot vnet.ibm.com
                   ` (2 preceding siblings ...)
  2020-03-20  7:43 ` rguenth at gcc dot gnu.org
@ 2020-03-20  9:53 ` rguenth at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-03-20  9:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94226

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-20  9:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 18:05 [Bug other/94226] New: [10 regression] r10-7272 eliminated some warning messages seurer at linux dot vnet.ibm.com
2020-03-19 18:44 ` [Bug middle-end/94226] " msebor at gcc dot gnu.org
2020-03-20  7:27 ` rguenth at gcc dot gnu.org
2020-03-20  7:43 ` rguenth at gcc dot gnu.org
2020-03-20  9:53 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).