[Issue 22480] New: Lack of template instantiation memoization for failed templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 4 15:49:02 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22480

          Issue ID: 22480
           Summary: Lack of template instantiation memoization for failed
                    templates
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eyal at weka.io

Example program:

  struct T(uint x) {
      pragma(msg, "Instantiated at ", x);
      static assert(x == 0);
  }

  static assert(is(T!0));
  static assert(is(T!0));
  static assert(!is(T!1));
  static assert(!is(T!1));         // redoes all the work :-(

prints:

  Instantiated at 0u
  Instantiated at 1u
  Instantiated at 1u

Sometimes, detecting an error in template instantiation can be costly.

If the compiler memoized not only template instantiation successes but also
failures, it can save compilation time and improve output when pragma(msg, ...)
are involved.

--


More information about the Digitalmars-d-bugs mailing list