public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/95998] gfc_typename use of static memory
Date: Sun, 12 Jul 2020 08:46:51 +0000 [thread overview]
Message-ID: <bug-95998-4-TaBATHa6z3@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 #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> 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.
OK. I think I am now starting to understand how this proc works.
I have looked at the occurrences of gfc_typename, and AFAICT they appear only
once or twice within
the same gfc_error, except for (line 2303 in check.c)
gfc_error ("The function passed as OPERATOR at %L has arguments of type "
"%s and %s but shall have type %s", &op->where,
gfc_typename (&formal->sym->ts),
gfc_typename (&formal->next->sym->ts), gfc_typename (a));
but 'a' is a gfc_expr, while 'formal->sym->ts', and 'formal->next->sym->ts' are
gfc_typespec, so different procs and it should be OK.
Note that presently gfc_typename is only called in error messages and potential
problems will
only show as strange errors.
However in noticed a potential buffer overflow with DEC extensions:
static char buffer1[GFC_MAX_SYMBOL_LEN + 7]; /* 7 for "TYPE()" + '\0'. */
static char buffer2[GFC_MAX_SYMBOL_LEN + 7];
should be
static char buffer1[GFC_MAX_SYMBOL_LEN + 8]; /* 8 for "UNION()" + '\0'. */
static char buffer2[GFC_MAX_SYMBOL_LEN + 8];
next prev parent reply other threads:[~2020-07-12 8:46 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 ` [Bug fortran/95998] " tkoenig at gcc dot gnu.org
2020-07-12 8:46 ` dominiq at lps dot ens.fr [this message]
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-TaBATHa6z3@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).