Bug 8497 – Regression 2.060: Bad code gen involving ubyte, ternary operators, and shifts
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2012-08-02T13:23:00Z
Last change time
2015-06-09T05:12:02Z
Assigned to
nobody
Creator
peter.alexander.au
Comments
Comment #0 by peter.alexander.au — 2012-08-02T13:23:12Z
Sorry for the title, don't know how to describe this well:
------------------
class Foo
{
public:
void foo(uint value)
{
ubyte size = value < (0x7fU << 0 ) ? 1 :
value < (0x7fU << 14) ? 2 :
3;
import std.stdio;
writeln(size);
}
}
void main()
{
Foo f = new Foo();
f.foo(1000000);
}
------------------
With no optimisations or any other flags, this prints out 255, even though it should print 2.
Happens in DMD 2.060, but not 2.059.
Comment #1 by peter.alexander.au — 2012-08-02T13:27:47Z