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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, no, that translation is not faithful, the original testcase has undefined
behavior.
The a array has 1024 elements, with indexes 1 to 1024.
So, when you use:
    DO x = 1, N, 16                                                             
       DO y = 1, 16                                                             
         ... a(x + y)
       END DO
    END DO
it doesn't do what you expect it to do, it doesn't access elements 1 to 1024,
but 2 to 1025 and the a(1025) read is where the UB is invoked.
I guess you meant either to do:
    DO x = 0, N - 1, 16
      DO y = 1, 16
or
    DO x = 1, N, 16
      DO y = 0, 15

Reply via email to