public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/19650] New: miscompilation of correct code
@ 2005-01-27 1:02 dalej at apple dot com
2005-01-27 1:08 ` [Bug middle-end/19650] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: dalej at apple dot com @ 2005-01-27 1:02 UTC (permalink / raw)
To: gcc-bugs
Following program miscompiles with -O1 on (32 bit) Darwin. Works with -O0.
It appears that RTL generation for
printf (&"cmp.func is %p (expected %p)\n"[0], comparator_matrixD.2001[0][(intD.2) (D.2150 == 2)],
compare_e_stringD.2019);
is incorrect, but I haven't dug deeply yet. I will be fixing this unless somebody recognizes it as a dup
#include <stdio.h>
#define test(a) ((a) ? 1 : 0)
typedef int (*arg_cmp_func)();
class Item_func
{
public:
enum Functype { UNKNOWN_FUNC, EQ_FUNC, EQUAL_FUNC };
virtual enum Functype functype() const { return UNKNOWN_FUNC; }
};
class Item_bool_func2 : public Item_func
{
public:
virtual enum Functype functype() const { return EQUAL_FUNC; }
};
class Arg_comparator
{
public:
Item_bool_func2 *owner;
arg_cmp_func func;
static arg_cmp_func comparator_matrix[4][2];
int Arg_comparator::set_compare_func(Item_bool_func2 *item, int type)
{
owner = item;
/****************** problematic line is here ************************/
func = comparator_matrix[type][test(owner->functype() == Item_func::EQUAL_FUNC)];
return 0;
}
};
int compare_string() { return 0; }
int compare_e_string() { return 0; }
int compare_real() { return 0; }
int compare_e_real() { return 0; }
int compare_int_signed() { return 0; }
int compare_e_int() { return 0; }
int compare_row() { return 0; }
int compare_e_row() { return 0; }
arg_cmp_func Arg_comparator::comparator_matrix[4][2] =
{{&compare_string, &compare_e_string},
{&compare_real, &compare_e_real},
{&compare_int_signed, &compare_e_int},
{&compare_row, &compare_e_row}};
int main()
{
Arg_comparator cmp;
Item_bool_func2 equal_func;
cmp.set_compare_func(&equal_func, 0);
printf("cmp.func is %p (expected %p)\n", cmp.func, &compare_e_string);
}
--
Summary: miscompilation of correct code
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dalej at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: same
GCC host triplet: powerpc-apple-darwin8.0.0.b3
GCC target triplet: same
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompilation of correct code
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
@ 2005-01-27 1:08 ` pinskia at gcc dot gnu dot org
2005-01-27 1:14 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-27 1:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-27 01:08 -------
Confirmed, This one is new to me.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2005-01-27 01:08:38
date| |
Summary|miscompilation of correct |[4.0 Regression]
|code |miscompilation of correct
| |code
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompilation of correct code
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
2005-01-27 1:08 ` [Bug middle-end/19650] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-01-27 1:14 ` pinskia at gcc dot gnu dot org
2005-01-27 1:21 ` dalej at apple dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-27 1:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-27 01:14 -------
And yes it looks like we are messing up the RTL generation for the printf, there is we don't compare
D.2150 to 2 at all.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompilation of correct code
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
2005-01-27 1:08 ` [Bug middle-end/19650] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-27 1:14 ` pinskia at gcc dot gnu dot org
@ 2005-01-27 1:21 ` dalej at apple dot com
2005-01-27 1:26 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dalej at apple dot com @ 2005-01-27 1:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dalej at apple dot com 2005-01-27 01:21 -------
OK, thanks, I'll go fix it. I mostly put it in here in case somebody was working on a dup.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |dalej at apple dot com
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompilation of correct code
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
` (2 preceding siblings ...)
2005-01-27 1:21 ` dalej at apple dot com
@ 2005-01-27 1:26 ` pinskia at gcc dot gnu dot org
2005-01-27 1:45 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-27 1:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-27 01:26 -------
Here is the most reduced testcase I came up with (this might be another type mismatch problem in
tree-ssa-phiopt but I could be wrong if you replace a1[0][i] by a[0][a==2] it works):
int g(void);
void h(int);
int a1[1][2]={{0,1}};
int main(void)
{
int a = g();
int i = (a==2)?1:0;
h(a1[0][i]);
return 0;
}
int g(void)
{
return 2;
}
extern "C" void abort(void);
void h(int a)
{
if (a!=1)
abort ();
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompilation of correct code
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
` (3 preceding siblings ...)
2005-01-27 1:26 ` pinskia at gcc dot gnu dot org
@ 2005-01-27 1:45 ` pinskia at gcc dot gnu dot org
2005-01-28 4:06 ` [Bug middle-end/19650] [4.0 Regression] miscompilating of array acess of (int)(a==2) cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-27 1:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-27 01:45 -------
Note here is the reduced C testcase which shows that this is not PHI-OPT bug as PHI-OPT does nothing:
int g(void);
void h(int);
int a1[2]={0,1};
int main(void)
{
int a = g();
_Bool i = a==2;
h(a1[i]);
return 0;
}
int g(void)
{
return 2;
}
extern void abort(void);
void h(int a)
{
if (a!=1)
abort ();
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompilating of array acess of (int)(a==2)
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
` (4 preceding siblings ...)
2005-01-27 1:45 ` pinskia at gcc dot gnu dot org
@ 2005-01-28 4:06 ` cvs-commit at gcc dot gnu dot org
2005-01-31 18:01 ` [Bug middle-end/19650] [4.0 Regression] miscompiling " cvs-commit at gcc dot gnu dot org
2005-01-31 18:27 ` dalej at apple dot com
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-28 4:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-01-28 04:06 -------
Subject: Bug 19650
CVSROOT: /cvs/gcc
Module name: gcc
Branch: apple-ppc-branch
Changes by: dalej@gcc.gnu.org 2005-01-28 04:06:25
Modified files:
gcc : ChangeLog.apple-ppc fold-const.c
gcc/testsuite : ChangeLog.apple-ppc
Added files:
gcc/testsuite/g++.dg: pr19650.C
Log message:
2005-01-26 Dale Johannesen <dalej@apple.com>
Radar 3974393
PR 19650
* fold-const.c (fold_binary_op_with_conditional_arg):
Make constant 0 or 1 be of correct type.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.2.288&r2=1.1.2.289
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.213.2.81.2.15&r2=1.213.2.81.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.apple-ppc.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.2.100&r2=1.1.2.101
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/pr19650.C.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompiling of array acess of (int)(a==2)
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
` (5 preceding siblings ...)
2005-01-28 4:06 ` [Bug middle-end/19650] [4.0 Regression] miscompilating of array acess of (int)(a==2) cvs-commit at gcc dot gnu dot org
@ 2005-01-31 18:01 ` cvs-commit at gcc dot gnu dot org
2005-01-31 18:27 ` dalej at apple dot com
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-01-31 18:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-01-31 18:01 -------
Subject: Bug 19650
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: dalej@gcc.gnu.org 2005-01-31 18:00:52
Modified files:
gcc : ChangeLog fold-const.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/opt: pr19650.C
Log message:
2005-01-31 Roger Sayle <roger@eyesopen.com>
Dale Johannesen <dalej@apple.com>
PR middle-end/19650
* fold-const.c (fold_binary_op_with_conditional_arg):
Make types match original operands, before STRIP_NOPS.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7341&r2=2.7342
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.499&r2=1.500
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4963&r2=1.4964
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr19650.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19650] [4.0 Regression] miscompiling of array acess of (int)(a==2)
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
` (6 preceding siblings ...)
2005-01-31 18:01 ` [Bug middle-end/19650] [4.0 Regression] miscompiling " cvs-commit at gcc dot gnu dot org
@ 2005-01-31 18:27 ` dalej at apple dot com
7 siblings, 0 replies; 9+ messages in thread
From: dalej at apple dot com @ 2005-01-31 18:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dalej at apple dot com 2005-01-31 18:27 -------
Fixed by patch above.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19650
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-01-31 18:27 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27 1:02 [Bug middle-end/19650] New: miscompilation of correct code dalej at apple dot com
2005-01-27 1:08 ` [Bug middle-end/19650] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-27 1:14 ` pinskia at gcc dot gnu dot org
2005-01-27 1:21 ` dalej at apple dot com
2005-01-27 1:26 ` pinskia at gcc dot gnu dot org
2005-01-27 1:45 ` pinskia at gcc dot gnu dot org
2005-01-28 4:06 ` [Bug middle-end/19650] [4.0 Regression] miscompilating of array acess of (int)(a==2) cvs-commit at gcc dot gnu dot org
2005-01-31 18:01 ` [Bug middle-end/19650] [4.0 Regression] miscompiling " cvs-commit at gcc dot gnu dot org
2005-01-31 18:27 ` dalej at apple dot com
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).