From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E14AB3857C5D; Sat, 11 Jul 2020 17:47:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E14AB3857C5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594489667; bh=0QYLvHDIW/6+Oqo0hN9/bz4WZ3rYwKmSrCHRON0KH2A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KMs1gQ/m6hTKoanDixr6JdjY0OSaxyCIVG6k4AS+zI0ggn6Le6uZWQuVm1FAZ4dTW EXOHkXMcA3lTDjXvcHPz9srn1rW6pv9QoUxf5Dkrxmxn9yUxR+XZx6+ZolDlhxGEfh o6uPxBSfQolk0SwwLTOAiesC7b0niiw7bbreG1q8= From: "tkoenig at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jul 2020 17:47:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95998 --- Comment #2 from Thomas Koenig --- (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? >=20 > static char buffer[GFC_MAX_SYMBOL_LEN + 7]; /* 7 for "TYPE()" + '\0'. = */ > gfc_typespec *ts1; > gfc_charlen_t length =3D 0; >=20 > 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 =3D gfc_typename(a); pb =3D gfc_typename(b); pc =3D gfc_typename(c); because then pa will point to the same memory as pc.=