public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113588] New: The vectorizer is introducing out-of-bounds memory access
@ 2024-01-24 23:05 kristerw at gcc dot gnu.org
  2024-01-24 23:17 ` [Bug tree-optimization/113588] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kristerw at gcc dot gnu.org @ 2024-01-24 23:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113588
           Summary: The vectorizer is introducing out-of-bounds memory
                    access
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristerw at gcc dot gnu.org
  Target Milestone: ---

The following function is miscompiled for x86_64 when compiled with
-O3 -march=x86-64-v2


unsigned long
foo (const char *s, unsigned long n)
{
 unsigned long len = 0;
 while (*s++ && n--)
   ++len;
 return len;
}


The original function reads two bytes from 's' when called as:

 char a[4];
 a[0] = 1;
 a[1] = 0;
 foo(a, 1000);

However, the vectorized function reads 16 bytes (thereby accessing the buffer
out of bounds) as it reads one vector at a time when s[0] != 0 and n >= 16.

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

end of thread, other threads:[~2024-02-03 22:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24 23:05 [Bug tree-optimization/113588] New: The vectorizer is introducing out-of-bounds memory access kristerw at gcc dot gnu.org
2024-01-24 23:17 ` [Bug tree-optimization/113588] [14 Regression] " pinskia at gcc dot gnu.org
2024-01-25  6:48 ` jakub at gcc dot gnu.org
2024-01-25  8:49 ` tnfchris at gcc dot gnu.org
2024-01-25  9:47 ` tnfchris at gcc dot gnu.org
2024-01-29 17:29 ` tnfchris at gcc dot gnu.org
2024-02-02 23:56 ` cvs-commit at gcc dot gnu.org
2024-02-03 22:03 ` sjames 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).