Garbage collected pointers?
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Thu Mar 1 20:10:39 UTC 2018
On Thursday, March 01, 2018 14:52:26 Steven Schveighoffer via Digitalmars-d-
learn wrote:
> On 3/1/18 2:04 PM, Jonathan M Davis wrote:
> > On Thursday, March 01, 2018 10:55:34 Steven Schveighoffer via
> > Digitalmars-d->
> > learn wrote:
> >> It should really say that it's up to the GC implementation whether it's
> >> UB or not.
> >
> > Well, that arguably makes it UB in general then, because it can't be
> > relied on. By putting restrictions on the GC in general based on what
> > types of GCs theoretically could be used, it makes it so that D code in
> > general could theoretically work with any GC that fits the bill,
> > whereas if the rules of what was allowed changed depending on the GC
> > being used, what was valid D would effectively change depending on the
> > GC.
>
> There are a few in there, which I think are over-the-top. Such as "don't
> cast a pointer to a non-pointer", or "Do not take advantage of alignment
> of pointers to store bit flags in the low order bits". I can't conceive
> of any GC that would have fits with either of these things without
> breaking pretty much everything. While I can't conceive of it, it
> doesn't mean there isn't a reason for it. But clearly the reason isn't
> currently implemented.
It would not surprise me in the least if the list of what's allowed and
isn't allowed in there needs an overhaul. I just think that saying that
something is okay with one GC and not with another such that whether the
code is valid or not depends on which GC is being used is begging for
trouble. The approach of saying what's allowed or not in general makes more
sense, even if the exact list needs work. And D and the plans for D have
changed enough over time that the current list could be making assumptions
about what's reasonable that actually aren't at all reasonable at this
point, particularly as it's become clearer over time that certain types of
GCs probably aren't reasonable, and if officially disallowing some of them
simplified things, then that may be a good idea. It hasn't mattered much in
practice though, because the work on alternative GCs has been minimal. There
have been some, but thus far, we haven't really ended up in a situation
where choosing which GC you're doing to use is much of a thing.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list