Bug 22322 – ImportC: struct with floating point members causes problems with generated toHash() function

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-09-19T16:35:02Z
Last change time
2021-09-30T01:46:14Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2021-09-19T16:35:02Z
The following C code fails to compile. struct S { float f; }; struct S2 { double d; }; Error: `tupleof` is not a member of `const(S)` Error: invalid `foreach` aggregate `_error_` Error: `tupleof` is not a member of `const(S2)` Error: invalid `foreach` aggregate `_error_` Note that the error messages do not have source location either!
Comment #1 by maxhaton — 2021-09-19T18:01:49Z
Could you try with -betterC and see if the error message remains?
Comment #2 by dave287091 — 2021-09-19T18:31:16Z
(In reply to mhh from comment #1) > Could you try with -betterC and see if the error message remains? The error goes away with -betterC.
Comment #3 by maxhaton — 2021-09-19T19:09:51Z
Ok, if this is with dmd master it's because recently it was made impossible to use .tupleof inside C code (long story...), however this seems to have disabled use of .tupleof when the C struct is being consumed inside D code as well. -betterC gets rid of the error which suggests to me that it's something to do with TypeInfo.
Comment #4 by dave287091 — 2021-09-19T19:23:12Z
(In reply to mhh from comment #3) > Ok, if this is with dmd master it's because recently it was made impossible > to use .tupleof inside C code (long story...), however this seems to have > disabled use of .tupleof when the C struct is being consumed inside D code > as well. > > -betterC gets rid of the error which suggests to me that it's something to > do with TypeInfo. It’s on the latest stable branch, commit 714c34ef8629c23751d7071d7dcc1d697708ad13 I just tried with master branch, commit 576ab617f5e84b8782752c1ebf5f5fd4beb1dac0 and the error is not there.
Comment #5 by maxhaton — 2021-09-19T19:28:05Z
Comment #6 by bugzilla — 2021-09-20T09:58:55Z
It sounds like it's trying to build the default struct member functions for it.
Comment #7 by bugzilla — 2021-09-21T06:30:53Z
The problem is in the buildXtoHash() function in clone.d. It adds .tupleof properties, whereas C files don't have such properties.
Comment #8 by dlang-bot — 2021-09-21T07:20:24Z
@WalterBright created dlang/dmd pull request #13091 "fix Issue 22322 - ImportC: struct with floating point members causes …" fixing this issue: - fix Issue 22322 - ImportC: struct with floating point members causes problems with generated toHash() function https://github.com/dlang/dmd/pull/13091
Comment #9 by dlang-bot — 2021-09-24T08:03:49Z
dlang/dmd pull request #13091 "fix Issue 22322 - ImportC: struct with floating point members causes …" was merged into stable: - b766b590098ef1a872c7f9222d49434d25086882 by Walter Bright: fix Issue 22322 - ImportC: struct with floating point members causes problems with generated toHash() function https://github.com/dlang/dmd/pull/13091
Comment #10 by dlang-bot — 2021-09-30T01:46:14Z
dlang/dmd pull request #13108 "merge stable" was merged into master: - efe4417cff053fe070061623f747c3018ccb88d4 by Walter Bright: fix Issue 22322 - ImportC: struct with floating point members causes problems with generated toHash() function (#13091) https://github.com/dlang/dmd/pull/13108