3 ms·
> A correctly-specified ABI should pass large structures by immutable reference is just not possible. CPUs don't know about `const`. So you have to work with t
by jcelerier 6y ago
> A correctly-specified ABI should pass large structures by immutable reference
is just not possible. CPUs don't know about `const`. So you have to work with the assumption that functions that you call can do anything to their arguments. Thus copies cannot be avoided.
- deleted 6y ago[deleted]
- mhh__ 6y agoThe CPU also doesn't know what an ABI is
- wizzwizz4 6y agoCPUs actually do know about const; it's called a read-only page. Besides, that's irrelevant. There's nothing stopping my function from following every pointer on the stack and smashing up its contents; are you going to defend against that, too? If not, how is this any different?
- jacoblambda 6y agoAn ABI also has a concept of defined and undefined behaviour. You can design an ABI that is fully protected against abuse but often the performance penalty for that will be huge. Instead what you'll do is specify the constrained inputs and expected output behaviour. From there you can out anything that violates those constraints as non-conformant. As long as you maintain those constraints between versions, there's no ABI breakage. Also you can absolutely have constant references in an ABI. There may be ways of ignoring the const depending on how you design the ABI but they will be obvious abuse.