public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/8023: Miscompilation of function grokdeclarator in c-decl.c at -O1 and above
@ 2002-09-29 13:35 danglin
0 siblings, 0 replies; 2+ messages in thread
From: danglin @ 2002-09-29 13:35 UTC (permalink / raw)
To: danglin, dave, gcc-bugs, gcc-prs, nobody
Synopsis: Miscompilation of function grokdeclarator in c-decl.c at -O1 and above
Responsible-Changed-From-To: unassigned->danglin
Responsible-Changed-By: danglin
Responsible-Changed-When: Sun Sep 29 13:35:23 2002
Responsible-Changed-Why:
Mine.
State-Changed-From-To: open->closed
State-Changed-By: danglin
State-Changed-When: Sun Sep 29 13:35:23 2002
State-Changed-Why:
http://gcc.gnu.org/ml/gcc-patches/2002-09/msg01714.html
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8023
^ permalink raw reply [flat|nested] 2+ messages in thread
* c/8023: Miscompilation of function grokdeclarator in c-decl.c at -O1 and above
@ 2002-09-24 9:46 dave
0 siblings, 0 replies; 2+ messages in thread
From: dave @ 2002-09-24 9:46 UTC (permalink / raw)
To: gcc-gnats
>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:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-09-29 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-29 13:35 c/8023: Miscompilation of function grokdeclarator in c-decl.c at -O1 and above danglin
-- strict thread matches above, loose matches on Subject: below --
2002-09-24 9:46 dave
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).