Bug 13992 – [REG2.067a] CTFE produces strange error with += operator on integer type
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-16T23:42:00Z
Last change time
2015-02-18T03:42:40Z
Keywords
CTFE, pull, rejects-valid
Assigned to
nobody
Creator
hsteoh
Comments
Comment #0 by hsteoh — 2015-01-16T23:42:05Z
Code:
------
void addListener() {
void delegate() tmp;
enum typehash = hashOf(tmp.mangleof.ptr, tmp.mangleof.length);
//hash_t typehash = hashOf(tmp.mangleof.ptr, tmp.mangleof.length);
}
@trusted hashOf( const void* buf, size_t len, hash_t seed = 0 )
{
auto data = cast(const (ubyte)*) buf;
auto hash = seed;
data += 2 ; // <---- this is line 11
hash += *data;
return hash;
}
------
Tested compiler: dmd git HEAD.
Compiler output:
------
eventloop.d(11): Error: integral constant must be scalar type, not const(void)
------
Note that if the "enum typehash" line is commented out and the following line uncommented, it works fine. This suggests that it's a CTFE issue. Both the "data += 2" and "hash += *data" lines are necessary; deleting either one makes the error message go away.
This code is reduced from a larger failing codebase that used to compile fine with earlier versions of dmd.