About const and C functions

bearophile bearophileHUGS at lycos.com
Wed Mar 2 04:06:47 PST 2011


Bekenn:

> I'm not sure that's checkable.  I think this falls squarely into the
> realm of "undefined behavior".

The signature of sscanf is something like:
int sscanf(char* str, char* format, ...);

Can't D/DMD err on the side of safety and consider the C-style variadic argument as not const, and so produce an error if you give to them something that's D const/immutable (and require a cast there)? (Especially a function like sscanf where the third and successive arguments are known to be modified).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list