https://issues.dlang.org/show_bug.cgi?id=18774
--- Comment #1 from [email protected] --- AIUI, all template functions that are instantiated will end up in the object file, even if they are only used during CTFE (i.e. the instantiation is triggered by CTFE but not anywhere else). This is a problem that's been bothering me too, which has led me to insert `if (__ctfe)` blocks into my CTFE functions. But if you're using Phobos functions, then you're out of luck. I agree that the compiler should have some way to track whether a particular template function / instantiation / etc., is only referenced by CTFE code, so that said functions are omitted from the object file when emitting code. Possibly something like a boolean flag in the template symbol to indicate whether the symbol is referenced by runtime constructs. I suspect, though, that this is far from trivial to implement, because code that gets run by CTFE is essentially just one step away from being emitted as object code, and for all intents and purposes is considered as "runtime" code by many parts of the compiler. So you get tricky things like whether a function called by a CTFE function should be marked as CTFE-only or should be included in the object file (since that function call would have been resolved before the CTFE engine even sees it, so it would already have been considered as "runtime", even if in actuality it will only ever be called from CTFE). Still, it's a nice-to-have. --
