public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4
@ 2005-01-24 16:00 heinrich dot brand at fujitsu-siemens dot com
2005-01-24 16:20 ` [Bug middle-end/19606] " falk at debian dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: heinrich dot brand at fujitsu-siemens dot com @ 2005-01-24 16:00 UTC (permalink / raw)
To: gcc-bugs
The value of test should be 0x7ffffffe and is 0xfffffffe;
Flags: none
(Also in 3.3.5)
#include <stdio.h>
signed char a=-4;
int test(){
return (((unsigned int)(signed int) a ) / 2LL) ;
}
int main(void){
int r;
r=test();
printf("test output: %#x == %d %x %x\n",r,r
,(r==0x7ffffffe),(r==0xfffffffe));
if(r == ( ((unsigned int)(signed int) (signed char) -4 ) / 2LL ))
printf("test successful\n");
else
printf("test failed\n");
return 0;
}
--
Summary: wrong code for arith.expr: (((unsigned int)(signed int)
a ) / 2LL) with signed char a=-4
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: heinrich dot brand at fujitsu-siemens dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: Intel-Linux
GCC host triplet: Intel-Linux
GCC target triplet: Intel-Linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19606
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/19606] wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4
2005-01-24 16:00 [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4 heinrich dot brand at fujitsu-siemens dot com
@ 2005-01-24 16:20 ` falk at debian dot org
2005-01-24 16:41 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: falk at debian dot org @ 2005-01-24 16:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From falk at debian dot org 2005-01-24 16:20 -------
Confirmed on alpha-linux. Has been broken since at least 2.95.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |wrong-code
Known to fail| |2.95.3 3.3.3 3.4.3 4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19606
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/19606] wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4
2005-01-24 16:00 [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4 heinrich dot brand at fujitsu-siemens dot com
2005-01-24 16:20 ` [Bug middle-end/19606] " falk at debian dot org
@ 2005-01-24 16:41 ` pinskia at gcc dot gnu dot org
2005-02-12 11:13 ` steven at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-24 16:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-24 16:41 -------
Also on powerpc-darwin.
--
What |Removed |Added
----------------------------------------------------------------------------
GCC build triplet|Intel-Linux |
GCC host triplet|Intel-Linux |
GCC target triplet|Intel-Linux |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19606
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/19606] wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4
2005-01-24 16:00 [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4 heinrich dot brand at fujitsu-siemens dot com
2005-01-24 16:20 ` [Bug middle-end/19606] " falk at debian dot org
2005-01-24 16:41 ` pinskia at gcc dot gnu dot org
@ 2005-02-12 11:13 ` steven at gcc dot gnu dot org
2005-02-12 13:50 ` steven at gcc dot gnu dot org
2005-02-12 15:32 ` [Bug c/19606] " steven at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-02-12 11:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-02-11 22:40 -------
Fails on i686 and on AMD64 also. And with both gcc and g++...
In c_finish_return, retval is "(long long int) (a / 2)". That is already
wrong.
In parser_build_binary_op we build TRUNC_DIV_EXPR <(unsigned int) a, 2LL>,
which is also already wrong (lost the "signed int" cast).
And so we dig deeper into the parser...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19606
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/19606] wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4
2005-01-24 16:00 [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4 heinrich dot brand at fujitsu-siemens dot com
` (2 preceding siblings ...)
2005-02-12 11:13 ` steven at gcc dot gnu dot org
@ 2005-02-12 13:50 ` steven at gcc dot gnu dot org
2005-02-12 15:32 ` [Bug c/19606] " steven at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-02-12 13:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-02-11 22:50 -------
And there was great rejoicing...
In c-typeck.c:
3253 ovalue = value;
(gdb) p debug_generic_expr (value)
(intD.0) aD.1454 // Good.
(gdb) next
3254 value = convert (type, value);
(gdb) p debug_generic_expr (ovalue)
(intD.0) aD.1454
(gdb) next
3257 if (TREE_CODE (value) == INTEGER_CST)
(gdb) p debug_generic_expr (value)
(unsigned intD.3) aD.1454
(gdb) p debug_generic_expr(type)
unsigned intD.3
So "convert (<unsigned int>, <(int) a>)" results in "<(unsigned int) a>" which
is wrong.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19606
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/19606] wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4
2005-01-24 16:00 [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4 heinrich dot brand at fujitsu-siemens dot com
` (3 preceding siblings ...)
2005-02-12 13:50 ` steven at gcc dot gnu dot org
@ 2005-02-12 15:32 ` steven at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-02-12 15:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From steven at gcc dot gnu dot org 2005-02-11 23:42 -------
Ignore comment #4, it's wrong.
An IRC debug session revealed that the call to get_narrower at c-typeck.c:7492
is incorrect; it's not being fed values properly converted to result_type.
A little archaeology shows that the offending code has been there since
forever (ie. it is in old-gcc).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19606
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-02-11 23:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-24 16:00 [Bug middle-end/19606] New: wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4 heinrich dot brand at fujitsu-siemens dot com
2005-01-24 16:20 ` [Bug middle-end/19606] " falk at debian dot org
2005-01-24 16:41 ` pinskia at gcc dot gnu dot org
2005-02-12 11:13 ` steven at gcc dot gnu dot org
2005-02-12 13:50 ` steven at gcc dot gnu dot org
2005-02-12 15:32 ` [Bug c/19606] " steven at gcc dot gnu dot org
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).