2014-02-18 0:48 GMT+09:00 Dicebot <public@dicebot.lv>:
On Monday, 17 February 2014 at 14:51:20 UTC, Kenji Hara wrote:
If a function is only used for CTFE, compiler can elide its codegen. It's
in the scope of optimization.

It can't know for sure it without some sort of WPO / LTO - and those won't happen any time soon. I propose a simple workaround that can be done right now (it can be optional compiler-specific addition)

In some case it would be possible without WPO/LTO:

- Immediately called lambdas

  enum x = (){ return some_sort_ctfe_calculartions; };   // lambda codegen is unnecessary.

- modue private functions

  module a;
  private string foo() { ... }
  enum x = foo();
  // Compiler can elide codegen for 'foo', if other declarations
  // in module a don't use it for runtime code.

Kenji Hara