Bug 22534 – ImportC: const pointer (not pointer to const) is treated as transitive const

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-11-22T05:50:01Z
Last change time
2021-12-14T10:34:29Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2021-11-22T05:50:01Z
A system header on macOS (<sys/_types/_fd_def.h>) actually has an inline function with a const pointer (not pointer to const). This header is transitively included by Python.h. The actual header has a lot of macro expanded junk, but it boils down to a function that looks like this: // constp.c struct S { int x; }; inline void setit(int i, struct S *const p){ p->x = i; // constp.c(6): Error: cannot modify `const` expression `(*p).x` }
Comment #1 by bugzilla — 2021-11-22T08:01:41Z
Hmm. The solution could be to simply ignore a top level const when it's a pointer.
Comment #2 by dlang-bot — 2021-12-02T18:54:39Z
@WalterBright created dlang/dmd pull request #13378 "fix Issue 22534 - ImportC: const pointer (not pointer to const) is tr…" fixing this issue: - fix Issue 22534 - ImportC: const pointer (not pointer to const) is treated as transitive const https://github.com/dlang/dmd/pull/13378
Comment #3 by dlang-bot — 2021-12-06T07:03:27Z
dlang/dmd pull request #13378 "fix Issue 22534 - ImportC: const pointer (not pointer to const) is tr…" was merged into stable: - d5d32f89ed381333b51452cfb21759889b0efd4b by Walter Bright: fix Issue 22534 - ImportC: const pointer (not pointer to const) is treated as transitive const https://github.com/dlang/dmd/pull/13378
Comment #4 by dlang-bot — 2021-12-14T10:34:29Z
dlang/dmd pull request #13421 "merge stable" was merged into master: - 9dc7b9ceaab7cd98aff5b4c6b396950ac9237233 by Walter Bright: fix Issue 22534 - ImportC: const pointer (not pointer to const) is treated as transitive const (#13378) https://github.com/dlang/dmd/pull/13421