public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.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 [thread overview] Message-ID: <bug-31282-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=31282 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 the same storage size as default INTEGER and REAL variables. The GNU Fortran internal representation is as follows. A LOGICAL(KIND=N) variable is represented as an INTEGER(KIND=N) variable, however, with only two permissible values: 1 for .TRUE. and 0 for .FALSE.. Any other integer value results in undefined behavior. ... 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(kind=4) ... 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 deal with this discrepancy, for instance here in f-valprint.c: ... /* The Fortran standard doesn't specify how logical types are represented. Different compilers use different non zero values to represent logical true. */ if (longval == 0) gdb_puts (f_decorations.false_name, stream); else gdb_puts (f_decorations.true_name, stream); ... -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2024-01-23 20:27 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-23 20:27 vries at gcc dot gnu.org [this message] 2024-01-24 1:10 ` [Bug fortran/31282] " tromey at sourceware dot org 2024-01-24 11:11 ` vries at gcc dot gnu.org 2024-01-24 12:16 ` vries at gcc dot gnu.org 2024-01-24 13:49 ` vries at gcc dot gnu.org 2024-01-24 16:58 ` tromey at sourceware dot org 2024-01-25 12:29 ` vries at gcc dot gnu.org 2024-01-25 14:57 ` tromey at sourceware dot org
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-31282-4717@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.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: linkBe 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).