public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/95998] gfc_typename use of static memory
Date: Sat, 11 Jul 2020 17:47:47 +0000	[thread overview]
Message-ID: <bug-95998-4-1cZVZWkBMe@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95998-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #1)
> Is static in C/C++ equivalent of SAVE in fortran (at least in the context of
> gfc_typename)?

Yes.

> If yes, AFAIU the code the odd access to gfc_typename use buffer2, while
> even ones
> use buffer1? Wouldn't it be simple (safer?) to use only buffer1?
> 
>   static char buffer[GFC_MAX_SYMBOL_LEN + 7];  /* 7 for "TYPE()" + '\0'.  */
>   gfc_typespec *ts1;
>   gfc_charlen_t length = 0;
> 
> Same thing for gfc_dummy_typename, gfc_typename, ... .

If we ever have three occurences of gfc_typename in a function list,
like

   foo (gfc_typename(a), gfc_typename(b), gfc_typename(c));

we will get the wrong result for the third one.  We will also get
a wrong result for

   pa = gfc_typename(a);
   pb = gfc_typename(b);
   pc = gfc_typename(c);

because then pa will point to the same memory as pc.

  reply	other threads:[~2020-07-11 17:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 12:17 [Bug fortran/95998] New: " dominiq at lps dot ens.fr
2020-07-11 17:47 ` tkoenig at gcc dot gnu.org [this message]
2020-07-12  8:46 ` [Bug fortran/95998] " dominiq at lps dot ens.fr
2021-03-28 12:33 ` dominiq at lps dot ens.fr

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-95998-4-1cZVZWkBMe@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).