Casting away const and invariant

Janice Caron caron800 at googlemail.com
Mon Sep 10 15:31:16 PDT 2007


On 9/10/07, Jeff Nowakowski <jeff at dilacero.org> wrote:

> And then what happens when you use a new version of the library, where
> your assumption is no longer valid?

Now you're just trying to cause trouble. :-)

A new version of strlen that modifies your string? Come on!

If /that/ assumption is no longer valid then you are the victim of a
malicious attack. You can't blame D for that, and nor can you protect
against it. A malicious attacker could declare the function as
strlen(const(char)[]) and /still/ modify the string.



> What's the *good* reason that const isn't the default, at least for
> function parameters?

Passing classes around, for one.



More information about the Digitalmars-d mailing list