public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104341] New: Bogus -Werror=array-bounds since r12-2582-gb9cbf8c9e0bc72f5
@ 2022-02-02  9:44 marxin at gcc dot gnu.org
  2022-02-02  9:58 ` [Bug tree-optimization/104341] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-02-02  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104341
           Summary: Bogus -Werror=array-bounds since
                    r12-2582-gb9cbf8c9e0bc72f5
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: msebor at gcc dot gnu.org
  Target Milestone: ---

Reduced from qemu package:

$ cat acpi.i
int memcpy_src_u_0_0, acpi_sx_zsdt_acpi;
char acpi_sx_zsdt_buf_0_0;
static void *memcpy2(void *dest, void *, int) {
  void *__trans_tmp_2 = dest;
  union {
    int u32[2];
  } *dest_u = __trans_tmp_2;
  dest_u->u32[0] = memcpy_src_u_0_0;
  return 0;
}
void copy_from_user(void *dest) {
  long __trans_tmp_4 = (long)dest, __trans_tmp_3 = __trans_tmp_4;
  memcpy2((void *)__trans_tmp_3, 0, 0);
}
int acpi_sx_zsdt() {
  copy_from_user(&acpi_sx_zsdt_acpi);
  return acpi_sx_zsdt_buf_0_0;
}

$ gcc acpi.i -c  -Werror=array-bounds -O2
In function ‘memcpy2’,
    inlined from ‘copy_from_user’ at acpi.i:13:3,
    inlined from ‘acpi_sx_zsdt’ at acpi.i:16:3:
acpi.i:8:18: error: array subscript ‘union <anonymous>[0]’ is partly outside
array bounds of ‘int[1]’ [-Werror=array-bounds]
    8 |   dest_u->u32[0] = memcpy_src_u_0_0;
      |   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
acpi.i: In function ‘acpi_sx_zsdt’:
acpi.i:1:23: note: object ‘acpi_sx_zsdt_acpi’ of size 4
    1 | int memcpy_src_u_0_0, acpi_sx_zsdt_acpi;
      |                       ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

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

end of thread, other threads:[~2022-03-08  0:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02  9:44 [Bug tree-optimization/104341] New: Bogus -Werror=array-bounds since r12-2582-gb9cbf8c9e0bc72f5 marxin at gcc dot gnu.org
2022-02-02  9:58 ` [Bug tree-optimization/104341] " pinskia at gcc dot gnu.org
2022-02-02 10:25 ` [Bug tree-optimization/104341] [12 Regression] " rguenth at gcc dot gnu.org
2022-03-08  0:03 ` msebor 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).