Bug 217 – typeof not working properly in internal/object.d

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-06-22T13:19:00Z
Last change time
2014-02-15T13:20:18Z
Assigned to
bugzilla
Creator
sean

Attachments

IDFilenameSummaryContent-TypeSize
182internal_object.d.diff.txtchange to using a less version specific set of aliasestext/plain1875

Comments

Comment #0 by sean — 2006-06-22T13:19:18Z
This bug appears related to the special handling DMD seems to have for compiling the object.d implementation file: internal/object.d. If the version blocks used to generate size_t and ptrdiff_t aliases (ie. lines 48-73) are removed and replaced by the more flexible aliases used in the global object.d header file: alias typeof(int.sizeof) size_t; alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; alias size_t hash_t; Then attempting to rebuild Phobos will generate these errors: \bin\dmd\bin\dmd -c -O -release -nofloat -w internal\object.d internal\object.d(388): function object.memcpy (void*,void*,typeof(4u)) does not match argument types (ubyte*,void*,uint) internal\object.d(388): cannot implicitly convert expression (sz) of type uint to typeof(4u) internal\object.d(389): function object.memcpy (void*,void*,typeof(4u)) does not match argument types (void*,void*,uint) internal\object.d(389): cannot implicitly convert expression (sz) of type uint to typeof(4u) internal\object.d(390): function object.memcpy (void*,void*,typeof(4u)) does not match argument types (void*,ubyte*,uint) internal\object.d(390): cannot implicitly convert expression (sz) of type uint to typeof(4u) internal\object.d(537): function object.memcmp (void*,void*,typeof(4u)) does not match argument types (void*,void*,uint) internal\object.d(537): cannot implicitly convert expression (this.xsize) of type uint to typeof(4u) internal\object.d(555): function object.memcmp (void*,void*,typeof(4u)) does not match argument types (void*,void*,uint) internal\object.d(555): cannot implicitly convert expression (this.xsize) of type uint to typeof(4u) --- errorlevel 1 I can't reproduce this elsewhere so I'm marking this bug as low priority, but it should probably be fixed at some point.
Comment #1 by braddr — 2007-09-17T00:55:03Z
It looks like it's a forward declaration issue with respect to alias and extern(C) functions. As long as the alias is before the extern(C) functions that use the aliases, it's fine. For example, calloc uses size_t. In the next attachment is a diff against dmd 1.021's internal/object.d that builds successfully. This isn't to say that there isn't a bug here, since order isn't supposed to matter, right?
Comment #2 by braddr — 2007-09-17T00:55:57Z
Created attachment 182 change to using a less version specific set of aliases
Comment #3 by braddr — 2007-10-20T03:24:02Z
The attachment was applied in 1.022/2.006, but the underlying but wasn't fixed. Here's a reduced test case for it: --------- extern(C) void bar(foo b); alias typeof(int.sizeof) foo; void main() { bar(1); } --------- results in: bug217.d(3): function bug217.bar (typeof(4u)) does not match parameter types (int) bug217.d(3): Error: cannot implicitly convert expression (1) of type int to typeof(4u) bug217.d(3): Error: cannot cast int to typeof(4u) bug217.d(3): Error: integral constant must be scalar type, not typeof(4u) If the first two lines are reversed, it builds fine.
Comment #4 by bugzilla — 2008-06-23T17:25:44Z
Same problem as #199 *** This bug has been marked as a duplicate of 199 ***
Comment #5 by bugzilla — 2008-06-23T17:26:51Z
oops, I meant 190
Comment #6 by bugzilla — 2008-06-23T17:27:11Z
*** This bug has been marked as a duplicate of 190 ***