public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96290] New: nonsensical bounds in VLA types in -Warray-bounds
@ 2020-07-22 20:06 msebor at gcc dot gnu.org
  2024-08-22 23:52 ` [Bug c/96290] " gabravier at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-07-22 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96290
           Summary: nonsensical bounds in VLA types in -Warray-bounds
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

VLA type mentioned in diagnostics involve nonsensical bounds.  The type should
instead be 'char[m][n]'

$ cat z.c && gcc -O2 -S -Wall z.c
#if 1
void f (void*);
void g (int m, int n)
{
  char a[m][n];
  a[-1][0] = 0;
  f (a);
}

z.c: In function ‘g’:
z.c:6:4: warning: array subscript -1 is below array bounds of ‘char[<U1ea0> +
1][<U1cf0> + 1]’ [-Warray-bounds]
    6 |   a[-1][0] = 0;
      |   ~^~~~


The C++ front end isn't much better:

z.c: In function ‘void g(int, int)’:
z.c:6:7: warning: array subscript -1 is below array bounds of ‘char
[(<anonymous> + 1)][(<anonymous> + 1)]’ [-Warray-bounds]
    6 |   a[-1][0] = 0;
      |   ~~~~^

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

* [Bug c/96290] nonsensical bounds in VLA types in -Warray-bounds
  2020-07-22 20:06 [Bug c/96290] New: nonsensical bounds in VLA types in -Warray-bounds msebor at gcc dot gnu.org
@ 2024-08-22 23:52 ` gabravier at gmail dot com
  2024-08-23  2:45 ` pinskia at gcc dot gnu.org
  2024-08-23  9:27 ` gabravier at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2024-08-22 23:52 UTC (permalink / raw)
  To: gcc-bugs

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

Gabriel Ravier <gabravier at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gabravier at gmail dot com

--- Comment #1 from Gabriel Ravier <gabravier at gmail dot com> ---
I've encountered a similarly nonsensical error on trunk, though not with VLAs,
instead with a char array of size 0:

#include <stdio.h>

int main(){
        puts(((char[0]){}));
}

<source>: In function 'main':
<source>:4:9: warning: 'puts' reading 1 or more bytes from a region of size 0
[-Wstringop-overread]
    4 |         puts(((char[0]){}));
      |         ^~~~~~~~~~~~~~~~~~~
<source>:4:24: note: source object '<U ea0>' of size 0
    4 |         puts(((char[0]){}));
      |                        ^
ASM generation compiler returned: 0
<source>: In function 'main':
<source>:4:9: warning: 'puts' reading 1 or more bytes from a region of size 0
[-Wstringop-overread]
    4 |         puts(((char[0]){}));
      |         ^~~~~~~~~~~~~~~~~~~
<source>:4:24: note: source object '<U ea0>' of size 0
    4 |         puts(((char[0]){}));
      |                        ^

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

* [Bug c/96290] nonsensical bounds in VLA types in -Warray-bounds
  2020-07-22 20:06 [Bug c/96290] New: nonsensical bounds in VLA types in -Warray-bounds msebor at gcc dot gnu.org
  2024-08-22 23:52 ` [Bug c/96290] " gabravier at gmail dot com
@ 2024-08-23  2:45 ` pinskia at gcc dot gnu.org
  2024-08-23  9:27 ` gabravier at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-23  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Gabriel Ravier from comment #1)
> I've encountered a similarly nonsensical error on trunk, though not with
> VLAs, instead with a char array of size 0:

It is not nonsensical at all. It just has an anonymous name for the object
which is different from the original issue of an anonynous name for the bounds.

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

* [Bug c/96290] nonsensical bounds in VLA types in -Warray-bounds
  2020-07-22 20:06 [Bug c/96290] New: nonsensical bounds in VLA types in -Warray-bounds msebor at gcc dot gnu.org
  2024-08-22 23:52 ` [Bug c/96290] " gabravier at gmail dot com
  2024-08-23  2:45 ` pinskia at gcc dot gnu.org
@ 2024-08-23  9:27 ` gabravier at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2024-08-23  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Gabriel Ravier <gabravier at gmail dot com> ---
Well, nonsensical from the point of view of the user - it didn't seem to be
particularly different to me for the error to evoke an object as "<U1ea0> + 1"
when it just means a VLA and "<U ea0>" when it just means an empty array (both
seem incomprehensible or at the very least pretty unexpected to the typical
user imo). Though, if you think this is a completely different bug I wouldn't
mind opening a different one, this just seemed like it had the same cause on
account of the instances of "<U.ea0>" being particularly similar.

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

end of thread, other threads:[~2024-08-23  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 20:06 [Bug c/96290] New: nonsensical bounds in VLA types in -Warray-bounds msebor at gcc dot gnu.org
2024-08-22 23:52 ` [Bug c/96290] " gabravier at gmail dot com
2024-08-23  2:45 ` pinskia at gcc dot gnu.org
2024-08-23  9:27 ` gabravier at gmail dot com

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).