On 3/5/18 1:08 PM, Stefan Koch wrote:
On Monday, 5 March 2018 at 18:04:20 UTC, Nordlöw wrote:
On Monday, 5 March 2018 at 16:07:49 UTC, Steven Schveighoffer wrote:
No, I mean you call holeKey at *runtime*. Inlined, it's just
returning a constant, so it should reduce to a constant.
A compile-time constant visible to the optimizer?
Yes indeed. For gdc and ldc the optimisation is guranteed and I am quite
dmd can do this as well. As long as you don't have too many statements.
Note, I think the error is bogus, you should be able to create
hard-coded addresses of data at compile time -- I'm not sure how you
would do hardware registers otherwise.
Another possibility I thought of:
struct Dummy
{
size_t nullValue;
void *holeKey;
}
enum holeKey = &(cast(Dummy *)null).holeKey;
But this fails as well
Error: dereference of null pointer null
-Steve