[PATCH] D49766: Fix a crash when an error occurs in Template and the initializer is a nullptr for C++17

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 25 13:43:37 PDT 2018


erik.pilkington added a comment.

Hi Balaji,

I reduced your testcase a bit more, this looks like the can be a crash on valid. Can you use the more minimal version in the testcase?

  template <typename a, int* = nullptr>
  struct e {
      e(a) {}
  };
  e c(0);

Also: you should add cfe-commits as a subscriber when creating new phab revisions. IIRC there was some issue with adding cfe-commits after the fact.



================
Comment at: include/clang/AST/TemplateBase.h:469
+
+    /* When an error occurs in a template value that is defaulted to
+       nullptr then the nullptr is left as-is and this function will
----------------
Please use `//` comments in C++ files!

I think this comment is pretty superfluous though. If a future reader came across this then they would probably not care too much about the details of this bug.


================
Comment at: include/clang/AST/TemplateBase.h:474-475
+       and proceeds through.  */
+    assert(Argument.getKind() == TemplateArgument::NullPtr ||
+           Argument.getKind() == TemplateArgument::Expression);
   }
----------------
I think we should let this constructor work with any non type template argument. If you agree, could you add the extra cases? (Should just be TemplateArgument::Declaration and TemplateArgument::Integral)


Repository:
  rC Clang

https://reviews.llvm.org/D49766





More information about the cfe-commits mailing list