public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: dave@hiauly1.hia.nrc.ca To: gcc-gnats@gcc.gnu.org Subject: c/8023: Miscompilation of function grokdeclarator in c-decl.c at -O1 and above Date: Tue, 24 Sep 2002 09:46:00 -0000 [thread overview] Message-ID: <20020924163955.19233.qmail@sources.redhat.com> (raw) >Number: 8023 >Category: c >Synopsis: Miscompilation of function grokdeclarator in c-decl.c at -O1 and above >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Tue Sep 24 09:46:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Dave Anglin >Release: gcc 3.2 and 3.3 (experimental) >Organization: >Environment: hppa64-hp-hpux11.00 >Description: The following test program char short *x23; should warn that a "long or short" was "specified with char". In trying to determine why the compiler doesn't warn, I found that the variable specbits is treated in inconsistently. The type of specbits is int (32 bits) but it appears that the compiler decides to treat it as a long (64 bits). However, there is a mixup in the subreg access. In some cases, it is accessed at offset 4 (correct) and in other cases it is accessed at offset 0 (incorrect). We have the following code and corresponding rtl at -O1 for the initialization of specbits at 387 of c-decl.c: specbits |= 1 << (int) i; (note 511 510 512 ("grokdeclarator.c") 387) (insn 512 511 513 0000000000000000 (set (reg:SI 215) (minus:SI (const_int 31 [0x1f]) (subreg:SI (reg/v:DI 182) 4))) -1 (nil) (nil)) (insn 513 512 514 0000000000000000 (set (reg:SI 214) (ashift:SI (const_int 1 [0x1]) (minus:SI (const_int 31 [0x1f]) (reg:SI 215)))) -1 (nil) (expr_list:REG_EQUAL (ashift:SI (const_int 1 [0x1]) (subreg:SI (reg/v:DI 182) 4)) (nil))) (insn 514 513 515 0000000000000000 (set (reg:SI 216) (ior:SI (reg:SI 214) (subreg/s:SI (reg/v:DI 74) 4))) -1 (nil) (nil)) (insn 515 514 516 0000000000000000 (set (reg/v:DI 74) (sign_extend:DI (reg:SI 216))) -1 (nil) (nil)) Then, up to line 478, specbits is accessed at offset 4 in DI 74, but a line 478 if ((specbits & 1 << (int) RID_LONG) && (specbits & 1 << (int) RID_SHORT)) error ("both long and short specified for `%s'", name); the following rtl is generated (note 882 881 883 ("grokdeclarator.c") 478) (insn 883 882 884 0000000000000000 (set (reg:SI 328) (const_int 132 [0x84])) -1 (nil) (nil)) (insn 884 883 885 0000000000000000 (set (reg:SI 327) (and:SI (subreg:SI (reg/v:DI 74) 0) (reg:SI 328))) -1 (nil) (nil)) So, the generated assembly code ands SI 327 with the high-order 32 bits instead of the low-order 32 bits of DI 74. This is why the proper warnings are not being generated. This doesn't appear to be a regression as 3.2 has the same behavior as 3.3. The code generated at -O0 is ok. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-09-24 16:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-09-24 9:46 dave [this message] 2002-09-29 13:35 danglin
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=20020924163955.19233.qmail@sources.redhat.com \ --to=dave@hiauly1.hia.nrc.ca \ --cc=gcc-gnats@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: 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).