From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C0C0838618B2; Tue, 30 Jun 2020 13:59:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0C0838618B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593525588; bh=xGH9FxgcKpUyX0PV17/yaEJILRtV/eW19rOPZ1dW6wI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mRLKr2az3b6RIjKWKplPv3Yn8cpl6L65QGmRMg6fMdP/r4zWo5JzNQkUJ2CJ4JPRK ao7xWVGb4q8bdf/BpS1B3CcJHMbDVR3cPyTc/rZYn5Qq3rC7y402X5OMZDAHJVp5Px XH1tz3PBwGmBHamIWW2njfONbtVTkIT1gBs92Su0= From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/95366] [10/11 Regression] TYPE IS(character(*)) no longer matches since r10-3605-gf61e54e59cda5a2e Date: Tue, 30 Jun 2020 13:59:48 +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: 10.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: tkoenig at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords bug_status assigned_to 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: Tue, 30 Jun 2020 13:59:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95366 Thomas Koenig changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ABI Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |tkoenig at gcc dot = gnu.org --- Comment #3 from Thomas Koenig --- The problem is in the hash, only a single bit seems to be different: +++ mod1.f90.004t.original 2020-06-30 07:14:25.582667830 +0000 @@ -105,7 +105,7 @@ } goto L.2; } - if (poly->_vptr->_hash =3D=3D 85893463) + if (poly->_vptr->_hash =3D=3D 85827864) { { integer(kind=3D8) D.2336; --- Comment #4 from Thomas Koenig --- And there are the diffs of the unzipped module files: [tkoenig@gcc135 Bad]$ diff ../Good/mod1.unzip mod1.unzip 37c37 < UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '85893463' --- > UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '85827864' [tkoenig@gcc135 Bad]$ diff ../Good/mod2.unzip mod2.unzip 24c24 < UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '85893463' --- > UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '16547404' Seems that change also broke the ABI :-( --- Comment #5 from Thomas Koenig --- Here are the differences in the -fdump-fortran-original files: --- ../Good/main.dump 2020-06-30 08:11:42.135005236 +0000 +++ main.dump 2020-06-30 08:09:57.907665704 +0000 @@ -4,7 +4,7 @@ symtree: '__vtab_CHARACTER_1_'|| symbol: '__vtab_CHARACTER_1_'=20 type spec : (DERIVED __vtype_CHARACTER_1_) attributes: (VARIABLE IMPLICIT-SAVE TARGET USE-ASSOC(mod2)) - value: __vtype_CHARACTER_1_(85893463 , () , () , () , () , NULL()) + value: __vtype_CHARACTER_1_(16547404 , () , () , () , () , NULL()) symtree: '__vtab_INTEGER_4_'|| symbol: '__vtab_INTEGER_4_'=20 type spec : (DERIVED __vtype_INTEGER_4_) attributes: (VARIABLE IMPLICIT-SAVE TARGET USE-ASSOC(mod2)) --- ../Good/mod1.dump 2020-06-30 08:08:08.780451149 +0000 +++ mod1.dump 2020-06-30 08:07:32.811369252 +0000 @@ -14,7 +14,7 @@ symtree: '__vtab_CHARACTER_1_'|| symbol: '__vtab_CHARACTER_1_'=20 type spec : (DERIVED __vtype_CHARACTER_1_) attributes: (VARIABLE PUBLIC IMPLICIT-SAVE TARGET) - value: __vtype_CHARACTER_1_(85893463 , 1_8 , NULL() , NULL() , __copy_character_1:__copy_character_1 , NULL()) + value: __vtype_CHARACTER_1_(85827864 , 1_8 , NULL() , NULL() , __copy_character_1:__copy_character_1 , NULL()) symtree: '__vtab_INTEGER_4_'|| symbol: '__vtab_INTEGER_4_'=20 type spec : (DERIVED __vtype_INTEGER_4_) attributes: (VARIABLE PUBLIC IMPLICIT-SAVE TARGET) @@ -143,7 +143,7 @@ DT_END END ASSOCIATE=20 - CASE (_loc[((mod1:__vtab_CHARACTER_1_))] 85893463)=20 + CASE (_loc[((mod1:__vtab_CHARACTER_1_))] 85827864)=20 ASSOCIATE =3D showpoly:poly % _data(FULL) symtree: 'block@3' || symbol: 'block@3'=20=20=20=20=20=20 --- ../Good/mod2.dump 2020-06-30 08:09:18.888661654 +0000 +++ mod2.dump 2020-06-30 08:08:55.019270915 +0000 @@ -4,7 +4,7 @@ symtree: '__vtab_CHARACTER_1_'|| symbol: '__vtab_CHARACTER_1_'=20 type spec : (DERIVED __vtype_CHARACTER_1_) attributes: (VARIABLE PUBLIC IMPLICIT-SAVE TARGET) - value: __vtype_CHARACTER_1_(85893463 , 1_8 , NULL() , NULL() , __copy_character_1:__copy_character_1 , NULL()) + value: __vtype_CHARACTER_1_(16547404 , 1_8 , NULL() , NULL() , __copy_character_1:__copy_character_1 , NULL()) symtree: '__vtab_INTEGER_4_'|| symbol: '__vtab_INTEGER_4_'=20 type spec : (DERIVED __vtype_INTEGER_4_) attributes: (VARIABLE PUBLIC IMPLICIT-SAVE TARGET) @@ -90,7 +90,7 @@ symtree: '__vtab_CHARACTER_1_'|| symbol: '__vtab_CHARACTER_1_'=20 type spec : (DERIVED __vtype_CHARACTER_1_) attributes: (VARIABLE IMPLICIT-SAVE TARGET USE-ASSOC(mod1)) - value: __vtype_CHARACTER_1_(85893463 , () , () , () , () , NULL()) + value: __vtype_CHARACTER_1_(85827864 , () , () , () , () , NULL()) symtree: '__vtab_INTEGER_4_'|| symbol: '__vtab_INTEGER_4_'=20 type spec : (DERIVED __vtype_INTEGER_4_) attributes: (VARIABLE IMPLICIT-SAVE TARGET USE-ASSOC(mod1)) So, basically the hash values for CHARACTER are all over the place. --- Comment #6 from Thomas Koenig --- In the bad revision, gfc_typename returns CHARACTER(0), in the good revision CHARACTER(1). --- Comment #7 from Thomas Koenig --- diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 2b760efe8d7..08705c7e95d 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -564,7 +564,7 @@ unsigned int gfc_intrinsic_hash_value (gfc_typespec *ts) { unsigned int hash =3D 0; - const char *c =3D gfc_typename (ts); + const char *c =3D gfc_typename (ts, true); int i, len; len =3D strlen (c); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 836e0b3063d..24c5101c4cb 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2931,7 +2931,7 @@ void gfc_clear_ts (gfc_typespec *); FILE *gfc_open_file (const char *); const char *gfc_basic_typename (bt); const char *gfc_dummy_typename (gfc_typespec *); -const char *gfc_typename (gfc_typespec *); +const char *gfc_typename (gfc_typespec *, bool for_hash =3D false); const char *gfc_typename (gfc_expr *); const char *gfc_op2string (gfc_intrinsic_op); const char *gfc_code2string (const mstring *, int); diff --git a/gcc/fortran/misc.c b/gcc/fortran/misc.c index 46c6277c2b9..25aefd3ab36 100644 --- a/gcc/fortran/misc.c +++ b/gcc/fortran/misc.c @@ -122,7 +122,7 @@ gfc_basic_typename (bt type) the argument list of a single statement. */ const char * -gfc_typename (gfc_typespec *ts) +gfc_typename (gfc_typespec *ts, bool for_hash) { static char buffer1[GFC_MAX_SYMBOL_LEN + 7]; /* 7 for "TYPE()" + '\0'. = */ static char buffer2[GFC_MAX_SYMBOL_LEN + 7]; @@ -149,6 +149,10 @@ gfc_typename (gfc_typespec *ts) sprintf (buffer, "LOGICAL(%d)", ts->kind); break; case BT_CHARACTER: + if (for_hash) + sprintf (buffer, "CHARACTER(%d)", ts->kind); + break; + if (ts->u.cl && ts->u.cl->length) length =3D gfc_mpz_get_hwi (ts->u.cl->length->value.integer); if (ts->kind =3D=3D gfc_default_character_kind) looks reasonably simple. --- Comment #8 from Thomas Koenig --- https://gcc.gnu.org/g:5958b926dcc3332aec0a2e34653c4394d2613401 commit r11-1729-g5958b926dcc3332aec0a2e34653c4394d2613401 Got the PR number wrong in the commit message... Author: Thomas Koenig Date: Tue Jun 30 13:01:36 2020 +0200 Use CHARACTER(kind) string for calculating the type hash. This regression came about because of a change in the way types are displayed in error messages. The character representation is also used to calculate the hashes for our types, so this patch restores the old behavior if we are indeed calculating a hash. The test case also checks for the specific hash value because changing that would be an ABI change, which we should not be doing unintentionally. gcc/fortran/ChangeLog: 2020-06-30 Thomas Koenig PR fortran/95355 * gfortran.h (gfc_typename): Add optional argument for_hash. * misc.c (gfc_typename): When for_hash is true, just retur CHARACTER(kind). * class.c (gfc_intrinsic_hash_value): Call gfc_typename with for_hash =3D true.=