From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C330E3858C41; Tue, 23 Jan 2024 20:27:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C330E3858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706041621; bh=wkQcnzAcWamXRYBpUV2i0rKk3z29wRr/+7wxM5gUqwY=; h=From:To:Subject:Date:From; b=Sws439U0lovXnurfsSPB/znQ9DgoY+6MJh02FII1yLJnPkYuZt/CfYmgHg5Ax+1WE 67Tbiumqf1MG/79PEas2yE5JnjbrAZ6LHaBGiNylrudChKuSbfH6kXKh4HMvoFMLfC ArMbHWI76XHxxby3mzBDAx2Am2+Rg11dkA1wkcAs= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug fortran/31282] New: [gdb/fortran] logical type doesn't match documentation of TYPE_CODE_BOOL Date: Tue, 23 Jan 2024 20:27:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: fortran X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31282 Bug ID: 31282 Summary: [gdb/fortran] logical type doesn't match documentation of TYPE_CODE_BOOL Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: fortran Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider the fortran type logical. Here ( https://gcc.gnu.org/onlinedocs/gfortran/Internal-representation-of-LOGICAL-= variables.html ) we read: ... The Fortran standard does not specify how variables of LOGICAL type are represented, beyond requiring that LOGICAL variables of default kind have t= he same storage size as default INTEGER and REAL variables. The GNU Fortran internal representation is as follows. A LOGICAL(KIND=3DN) variable is represented as an INTEGER(KIND=3DN) variabl= e, however, with only two permissible values: 1 for .TRUE. and 0 for .FALSE.. = Any other integer value results in undefined behavior.=20 ... OK, that's clear. So how does this look in dwarf? Like so: ... <1><106>: Abbrev Number: 1 (DW_TAG_base_type) <107> DW_AT_byte_size : 4 <108> DW_AT_encoding : 2 (boolean) <109> DW_AT_name : (indirect string, offset: 0x6): logical(kin= d=3D4) ... So, is there a clue to tell what the values of true/false are, other than looking at the producer string and searching for "GNU Fortran"? DW_AT_encoding ATE_boolean has the description of "true or false", so that doesn't seem to help much. However, internally in gdb, this type is mapped onto: ... /* * Boolean type. 0 is false, 1 is true, and other values are non-boolean (e.g. FORTRAN "logical" used as unsigned int). */ OP (TYPE_CODE_BOOL) ... That doesn't seem correct. If .TRUE. is, say 2, then using TYPE_CODE_BOOL tells us to view it as non-boolean. AFAICT this doesn't cause any trouble because there's special handling to d= eal with this discrepancy, for instance here in f-valprint.c: ... /* The Fortran standard doesn't specify how logical types are=20= =20=20=20=20=20=20=20=20 represented. Different compilers use different non zero=20=20= =20=20=20=20=20=20=20=20=20 values to represent logical true. */ if (longval =3D=3D 0) gdb_puts (f_decorations.false_name, stream); else gdb_puts (f_decorations.true_name, stream); ... --=20 You are receiving this mail because: You are on the CC list for the bug.=