[Issue 3558] New: Optimizer bug results in false if condition being taken
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 29 05:28:06 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3558
Summary: Optimizer bug results in false if condition being
taken
Product: D
Version: unspecified
Platform: x86
OS/Version: Linux
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: janzert at janzert.com
--- Comment #0 from Janzert <janzert at janzert.com> 2009-11-29 05:28:04 PST ---
I've been chasing a bug for a few days and finally have it narrowed down to the
following example. Basically a condition that should evaluate to false is taken
anyway.
The printf line below should never be executed, but it is if compiled under
linux with "dmd -release -O -inline badbranch.d".
I first started chasing this while using 1.043 but have since upgraded to 1.052
and still see it. Not surprisingly I also see it with phobos or tango. It has
also been reported to behave the same with 2.034.
badbranch.d:
extern(C) int printf(char*, ...);
struct Container
{
ulong[2] bits = [0UL, 1];
}
int called(ulong value)
{
value = value * 3;
return value;
}
int test(Container* c, int[] shift)
{
int count = 0;
if (c.bits[0])
count = 1;
count |= called(c.bits[1]) << shift[0];
// This is always false, but is taken anyway.
if (c.bits[0])
printf("Impossible output %lld\n", c.bits[0]);
return count;
}
int main(char[][] args)
{
int[] shift = [0];
Container c;
return test(&c, shift);
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list