[Issue 22759] ImportC: cannot modify const expression from dereferencing const pointer declared within function.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 2 15:34:24 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22759
Steven Schveighoffer <schveiguy at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at gmail.com
--- Comment #5 from Steven Schveighoffer <schveiguy at gmail.com> ---
An idea that just came up on discord -- what if D just pretended C head const
was mutable? In practice, you are making a copy anyway, and the implementation
isn't actually affected since you might assume that the code would already be
compiling on existing C compilers.
Credit to Adam Ruppe for the idea.
So in the example, `int * const p` just becomes `int * p`, along with all the
other code pieces.
You can keep the fact that const was present in the AST as a note, in case you
need to print something or in case you at some point decide to enforce
head-const.
--
More information about the Digitalmars-d-bugs
mailing list