weird bug with nested functions:

Johannes Pfau nospam at example.com
Fri Feb 8 05:05:24 PST 2013


https://gist.github.com/jpf91/4738922

/tmp/cc8D6NeD.o:(.rodata._D6nested10__T5f7965Z5f7965FNaNbNfZC6nested10__T5f7965Z5f79656Result6Result6__vtblZ[_D6nested10__T5f7965Z5f7965FNaNbNfZC6nested10__T5f7965Z5f79656Result6Result6__vtblZ]+0x30):
undefined reference to
`_D6nested10__T5f7965Z5f7965FNaNbNfZC6nested10__T5f7965Z5f79656Result6Result1gMFZv'

This is currently not detected as needing a closure, it tries to use
the gcc nested function mechanism. I guess the gcc mechanism can't
handle function->class->function chains as it was developed for c
nested functions which can only be nested in functions AFAIK.

Background info: We don't call cgraph_finalize_function for GCC nested
functions (ObjectFile::outputFunction). This is correct, as
cgraph_finalize_function is called by the GCC middle / backend. But I
think in this case we're passing something to the backend which it can't
handle. Therefore cgraph_finalize_function is never called and the
function is not put out.

Uncommenting the /*a = 42;*/ makes everything work as we use the D
closure code path in that case. Marking the Result class as static also
works.

Do you know how we could force the D closure codepath in such cases or
how we should solve this?

(I actually found a fix for that verify_callgraph problem. But it
triggered some regressions which are actually caused by this bug.)




More information about the D.gnu mailing list