public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters
@ 2021-07-22 22:18 jahns at dkrz dot de
  2021-07-23  0:01 ` [Bug c/101585] [11/12 Regression] " msebor at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jahns at dkrz dot de @ 2021-07-22 22:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101585
           Summary: Bad interaction of -fsanitize=undefined and
                    -Wvla-parameters
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jahns at dkrz dot de
  Target Milestone: ---

The following source causes an incorrect warning with gcc 11.1.0 (sorry did not
have 11.1.1 available, it's not yet in spack):

void a(long send_size_asize, int (*)[send_size_asize]);
void a(long send_size_asize, int (*)[send_size_asize]) {}

Compiling it with

gcc-11.1 -c -Wall -Werror -fsanitize=undefined mini.c

results in

mini.c:2:30: error: mismatch in bound 1 of argument 2 declared as 'int
(*)[(send_size_asize) - 1]'
[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wvla-parameter-Werror=vla-parameter]8;;]
    2 | void a(long send_size_asize, int (*)[send_size_asize]) {}
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
mini.c:1:30: note: previously declared as 'int (*)[(send_size_asize) - 1]'
    1 | void a(long send_size_asize, int (*)[send_size_asize]);
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

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

* [Bug c/101585] [11/12 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
@ 2021-07-23  0:01 ` msebor at gcc dot gnu.org
  2021-07-23  0:02 ` msebor at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-23  0:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Bad interaction of          |[11/12 Regression] Bad
                   |-fsanitize=undefined and    |interaction of
                   |-Wvla-parameters            |-fsanitize=undefined and
                   |                            |-Wvla-parameters
     Ever confirmed|0                           |1
                 CC|                            |msebor at gcc dot gnu.org
      Known to fail|                            |11.1.0, 12.0
           Keywords|                            |diagnostic
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-07-23

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed.  It looks like an oversight in r12-2329.  The following fixes it:

diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 552a29f9944..7a50baedea9 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -3275,7 +3275,8 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree
curparms, tree newparms)
          /* Move on if the bounds look the same.  */
          if (!pcurbndpos && !pnewbndpos
              && curbnd && newbnd
-             && operand_equal_p (curbnd, newbnd, OEP_LEXICOGRAPHIC))
+             && operand_equal_p (curbnd, newbnd, OEP_LEXICOGRAPHIC
+                                 | OEP_DECL_NAME))
            continue;

          if ((curbnd && TREE_CODE (curbnd) != INTEGER_CST)

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

* [Bug c/101585] [11/12 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
  2021-07-23  0:01 ` [Bug c/101585] [11/12 Regression] " msebor at gcc dot gnu.org
@ 2021-07-23  0:02 ` msebor at gcc dot gnu.org
  2021-07-27 19:52 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-23  0:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.2

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

* [Bug c/101585] [11/12 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
  2021-07-23  0:01 ` [Bug c/101585] [11/12 Regression] " msebor at gcc dot gnu.org
  2021-07-23  0:02 ` msebor at gcc dot gnu.org
@ 2021-07-27 19:52 ` cvs-commit at gcc dot gnu.org
  2021-07-27 20:33 ` [Bug c/101585] [11 " msebor at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-27 19:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:a0f9a5dcc3bbe6c7de499e17d201d0f2cb512649

commit r12-2541-ga0f9a5dcc3bbe6c7de499e17d201d0f2cb512649
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Jul 27 13:51:55 2021 -0600

    Use OEP_DECL_NAME when comparing VLA bounds [PR101585].

    Resolves:
    PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters

    gcc/c-family:

            PR c/101585
            * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME.

    gcc/testsuite:
            PR c/101585
            * gcc.dg/Wvla-parameter-13.c: New test.

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

* [Bug c/101585] [11 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
                   ` (2 preceding siblings ...)
  2021-07-27 19:52 ` cvs-commit at gcc dot gnu.org
@ 2021-07-27 20:33 ` msebor at gcc dot gnu.org
  2021-07-28  7:07 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-27 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression] Bad      |[11 Regression] Bad
                   |interaction of              |interaction of
                   |-fsanitize=undefined and    |-fsanitize=undefined and
                   |-Wvla-parameters            |-Wvla-parameters
      Known to fail|12.0                        |

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed in GCC 12.  Will backport to GCC 11.

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

* [Bug c/101585] [11 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
                   ` (3 preceding siblings ...)
  2021-07-27 20:33 ` [Bug c/101585] [11 " msebor at gcc dot gnu.org
@ 2021-07-28  7:07 ` rguenth at gcc dot gnu.org
  2022-04-07 10:40 ` cvs-commit at gcc dot gnu.org
  2022-04-07 10:40 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

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

* [Bug c/101585] [11 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
                   ` (4 preceding siblings ...)
  2021-07-28  7:07 ` rguenth at gcc dot gnu.org
@ 2022-04-07 10:40 ` cvs-commit at gcc dot gnu.org
  2022-04-07 10:40 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-07 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:5446b933bc1e9449aa408eb66c31b6fcdbe74214

commit r11-9788-g5446b933bc1e9449aa408eb66c31b6fcdbe74214
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Jul 27 13:51:55 2021 -0600

    Use OEP_DECL_NAME when comparing VLA bounds [PR101585].

    Resolves:
    PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters

    gcc/c-family:

            PR c/101585
            * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME.

    gcc/testsuite:
            PR c/101585
            * gcc.dg/Wvla-parameter-13.c: New test.

    (cherry picked from commit a0f9a5dcc3bbe6c7de499e17d201d0f2cb512649)

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

* [Bug c/101585] [11 Regression] Bad interaction of -fsanitize=undefined and -Wvla-parameters
  2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
                   ` (5 preceding siblings ...)
  2022-04-07 10:40 ` cvs-commit at gcc dot gnu.org
@ 2022-04-07 10:40 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-07 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2022-04-07 10:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 22:18 [Bug c/101585] New: Bad interaction of -fsanitize=undefined and -Wvla-parameters jahns at dkrz dot de
2021-07-23  0:01 ` [Bug c/101585] [11/12 Regression] " msebor at gcc dot gnu.org
2021-07-23  0:02 ` msebor at gcc dot gnu.org
2021-07-27 19:52 ` cvs-commit at gcc dot gnu.org
2021-07-27 20:33 ` [Bug c/101585] [11 " msebor at gcc dot gnu.org
2021-07-28  7:07 ` rguenth at gcc dot gnu.org
2022-04-07 10:40 ` cvs-commit at gcc dot gnu.org
2022-04-07 10:40 ` 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).