This is an automated email from the ASF dual-hosted git repository.

jroesch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
     new 896557d  [RUNTIME] Resolve constexpr issue in debug mode. (#5651)
896557d is described below

commit 896557d935999391dcc8bda001fb67d79e2f9ef8
Author: Tianqi Chen <tqc...@users.noreply.github.com>
AuthorDate: Fri May 22 13:36:43 2020 -0700

    [RUNTIME] Resolve constexpr issue in debug mode. (#5651)
    
    static constexpr is a bit weird before c++17.
    They are not inlined by default and does not have symbols after compilation.
    It usually isn't a problem when they are inlined(in c++17 they are inlined 
by default).
    But will create compilation error when passed to functions that take 
(const)references.
    This PR fixes the problem so that we can compile on debugmode.
---
 include/tvm/runtime/container.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/tvm/runtime/container.h b/include/tvm/runtime/container.h
index a52e997..1569c67 100644
--- a/include/tvm/runtime/container.h
+++ b/include/tvm/runtime/container.h
@@ -491,10 +491,10 @@ class ArrayNode : public Object, public 
InplaceArrayBase<ArrayNode, ObjectRef> {
   int64_t capacity_;
 
   /*! \brief Initial size of ArrayNode */
-  static const constexpr int64_t kInitSize = 4;
+  static constexpr int64_t kInitSize = 4;
 
   /*! \brief Expansion factor of the Array */
-  static const constexpr int64_t kIncFactor = 2;
+  static constexpr int64_t kIncFactor = 2;
 
   // CRTP parent class
   friend InplaceArrayBase<ArrayNode, ObjectRef>;
@@ -929,7 +929,9 @@ class Array : public ObjectRef {
   ArrayNode* CopyOnWrite(int64_t reserve_extra) {
     ArrayNode* p = GetArrayNode();
     if (p == nullptr) {
-      return SwitchContainer(std::max(ArrayNode::kInitSize, reserve_extra));
+      // necessary to get around the constexpr address issue before c++17
+      const int64_t kInitSize = ArrayNode::kInitSize;
+      return SwitchContainer(std::max(kInitSize, reserve_extra));
     }
     if (p->capacity_ >= p->size_ + reserve_extra) {
       return CopyOnWrite();

Reply via email to