public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xecej4 at outlook dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/113165] New: Code containing more than one type declaration for a variable results in confusing error messages from compiler
Date: Thu, 28 Dec 2023 15:21:01 +0000	[thread overview]
Message-ID: <bug-113165-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113165
           Summary: Code containing more than one type declaration for a
                    variable results in confusing error messages from
                    compiler
           Product: gcc
           Version: 11.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xecej4 at outlook dot com
  Target Milestone: ---

Created attachment 56960
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56960&action=edit
Fixed form Fortran77 source file that causes compiler to issue confusing
messages

Some old Fortran codes (e.g., www.netlib.org/ode/epsode.f ) may contain
duplicate declarations of some variables. Lines 1239-1241 of epsode.f:

      double precision eps, epsj, h, hmax, hmin, pw, save1, save2,
     1                 ss, t, uround, ymax
      double precision d, r, r0, t, yj

The variable t is declared twice, albeit with the same type and kind.

Gfortran correctly flags this error, but seems to go farther and mark the
variable t as implicitly typed single precision REAL, causing the issuing a
number of misleading error messages when the concerned variable is used in
expressions later on in the program unit.

I enclose a short program to illustrate. Please compile the program with (a) no
options, (b) with -Wall and (c) with -fimplicit-none. Case (c) results in:

muldecl.f:4:24:

    4 |       double precision d,q,r  ! 'd' was already declared as double
prec.
      |                        1
Error: Symbol 'd' at (1) already has basic type of REAL
muldecl.f:7:7:

    7 |       r = sqrt(d)
      |       1
Error: Symbol 'r' at (1) has no IMPLICIT type

I suspect that the multiple declaration of d has caused even the unrepeated
declaration of r to be tainted.

             reply	other threads:[~2023-12-28 15:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-28 15:21 xecej4 at outlook dot com [this message]
2023-12-28 17:46 ` [Bug fortran/113165] " kargl at gcc dot gnu.org
2023-12-28 20:54 ` kargl at gcc dot gnu.org
2023-12-29 13:43 ` xecej4 at outlook dot com

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=bug-113165-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).