public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Arjen Markus <arjen.markus895@gmail.com>
To: Vivek Rao <vivekrao4@yahoo.com>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Subject: Re: spurious out-of-bounds warning message
Date: Thu, 13 Jul 2023 13:53:27 +0200	[thread overview]
Message-ID: <CAMCbSMqYQAH1hTiwECQsrO=oy56em52v8J7QCWmvzGb48brLkg@mail.gmail.com> (raw)
In-Reply-To: <919875339.3066299.1689174303551@mail.yahoo.com>

[-- Attachment #1: Type: text/plain, Size: 935 bytes --]

I would say it is indeed very hard to capture all false positves.

Regards,

Arjen

Op wo 12 jul 2023 om 17:05 schreef Vivek Rao via Fortran <
fortran@gcc.gnu.org>:

> For the code
>
> program main
> implicit none
> integer, parameter :: n = 10
> real :: x(n), dx(n)
> integer :: i
> call random_number(x)
> do i=1,n
>    if (i > 1) then
>       dx(i) = x(i) - x(i-1)
>    else
>       dx(i) = 0.0
>    end if
> end do
> print*,dx
> end program main
>
> gfortran -Wextra says for GNU Fortran (GCC) 13.0.0 20221218
>
> xspur.f90:9:23:
>
>
>     7 | do i=1,n
>       |        2
>     8 |    if (i > 1) then
>     9 |       dx(i) = x(i) - x(i-1)
>       |                       1
> Warning: Array reference at (1) out of bounds (0 < 1) in loop beginning at
> (2) [-Wdo-subscript]
>
> but the code is fine because of the if guard. Ideally such spurious
> messages would be suppressed, but I don't know if this is too hard.
>
> Vivek Rao
>

      reply	other threads:[~2023-07-13 11:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <919875339.3066299.1689174303551.ref@mail.yahoo.com>
2023-07-12 15:05 ` Vivek Rao
2023-07-13 11:53   ` Arjen Markus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMCbSMqYQAH1hTiwECQsrO=oy56em52v8J7QCWmvzGb48brLkg@mail.gmail.com' \
    --to=arjen.markus895@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=vivekrao4@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).