[Issue 13992] New: CTFE produces strange error with += operator on integer type
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jan 16 15:42:05 PST 2015
https://issues.dlang.org/show_bug.cgi?id=13992
Issue ID: 13992
Summary: CTFE produces strange error with += operator on
integer type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
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.
--
More information about the Digitalmars-d-bugs
mailing list