D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4837 - ICE(constfold.c) CTFE with >>>=
Summary: ICE(constfold.c) CTFE with >>>=
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: simon
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-09-07 13:05 UTC by Stanislav Blinov
Modified: 2011-08-24 12:58 UTC (History)
2 users (show)

See Also:


Attachments
PATCH against rev 755: remove superfluous asserts (573 bytes, patch)
2010-11-15 12:24 UTC, simon
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Stanislav Blinov 2010-09-07 13:05:21 UTC
Compilation fails with assertion in constfold.c:608 or constfold.c:614 for the following code:

bool foo(T)(T t)
{
    t >>>= 1;       // triggers assertion for ubytes and ushorts
    // t = t >>> 1; // this compiles with no errors
    return true;
}

void main()
{
    auto g1 = foo!ubyte(1); // Ok for runtime
    auto g2 = foo!ushort(1); // Ok for runtime

    // CTFE:
    enum e1 = foo!ubyte(1);  // Assertion failure: '0' on line 608 in file 'constfold.c'
    enum e2 = foo!ushort(1); // Assertion failure: '0' on line 614 in file 'constfold.c'
}

DMD 2.048
Comment 1 simon 2010-11-15 12:24:38 UTC
Created attachment 814 [details]
PATCH against rev 755: remove superfluous asserts

fixed, no idea why asserts where placed in there.
unsigned shifting of 8 ^ 16 bit values seems perfectly reasonable.
Comment 2 Don 2010-11-15 12:39:53 UTC
(In reply to comment #1)
> Created an attachment (id=814) [details]
> PATCH against rev 755: remove superfluous asserts
> 
> fixed, no idea why asserts where placed in there.
> unsigned shifting of 8 ^ 16 bit values seems perfectly reasonable.

The problem is that the code there gives different results to what happens in all other situations. See bug 2809. 
As far as I can tell, >>> is a broken concept. Andrei and I tried to get it removed from the language before publication of TDPL, but we failed.
Comment 3 Brad Roberts 2011-02-06 15:39:40 UTC
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.