H. S. Teoh <hst...@quickfur.ath.cx> wrote:
> On Tue, Aug 28, 2018 at 10:20:06AM -0700, Manu via Digitalmars-d wrote:
> [...]
> Actually, I think C++ const is not very useful, because it guarantees
> nothing. At the most, it's just a sanity checker to make sure the
> programmer didn't accidentally do something dumb. But given an opaque
> C++ function that takes const parameters, there is ZERO guarantee that
> it doesn't actually modify stuff behind your back, and do so legally
> (per spec).

No, casting away const on pointers and references is only legal if the
object pointed to is actually mutable (not const). Everything else is UB.
Casting away const of a function parameter that is not under your control
will sooner or later lead to UB.

Tobi

Reply via email to