I can crash program (core.exception.InvalidMemoryOperationError) by using __FUNCTION__ in a class ctor

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Jan 18 19:09:27 UTC 2019


On Friday, January 18, 2019 12:03:23 PM MST H. S. Teoh via Digitalmars-d 
wrote:
> On Fri, Jan 18, 2019 at 11:37:02AM -0700, Jonathan M Davis via
> Digitalmars-d wrote: [...]
>
> > The safest thing for anyone wanting to use std.internal.cstring is to
> > just copy the module into their own project, though arguably, it's one
> > of those things that should be cleaned up and made public instead of
> > being in internal (which would actually break any code currently using
> > std.internal.cstring). Regardless, I would definitely _not_ advise
> > anyone to just import something from internal, and I definitely don't
> > want to see anyone trying to argue later that we can't change
> > something from internal just because a bunch of people decided that
> > something from there was useful and started importing it. While the
> > risk of your code breaking later on because it's using something from
> > internal _might_ be low, it is basically begging for it to be broken
> > at some point.
>
> [...]
>
> Shouldn't std.internal.* declare all symbols as private to std.*, like
> with `package` or something? Or is that not expressible currently?
>
> It's a pretty bad idea for user code to depend on std.internal.*...

It should be possible to make it package(std), and really, it should be, but
it probably predates being able to do that, since that's a recent-ish
feature. It's also something that I think folks tend to forget about (I
certainly do), because it doesn't get used often.

- Jonathan M Davis





More information about the Digitalmars-d mailing list