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.
Comment #1 by k.hara.pg — 2015-01-17T06:45:03Z
Comment #2 by github-bugzilla — 2015-01-19T15:47:33Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c8d49c79d3a68b509b1046f4280169232b6f52db fix Issue 13992 - CTFE produces strange error with += operator on integer type https://github.com/D-Programming-Language/dmd/commit/2ec6abc0d5eafdf44a84405d9457ea9ad5199025 Merge pull request #4304 from 9rnsr/fix13992 [REG2.067a] Issue 13992 - CTFE produces strange error with += operator on integer type
Comment #3 by github-bugzilla — 2015-02-18T03:42:40Z