[PATCH] D113859: [Sema] Fix consteval function calls with value-dependent args

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 18 23:18:54 PDT 2022


usaxena95 added a comment.
Herald added a project: All.

Update: The mentioned cases here are all now fixed at head (after D132031 <https://reviews.llvm.org/D132031>)

  // 1
  consteval int f(int n) { return n; }
  
  template <int M>
  constexpr int broken() {
    return f(M);
  }
  static_assert(broken<100>() == 100);
  
  // 2
  template <typename T>
  struct Foo {
      static consteval void ok(int) {}
  
      static consteval void bad(T) {}
  
      template <typename U>
      static consteval void call(T x, U fn) { fn(x); }
  
      static constexpr bool test() {
          ok({});
          bad({});  // error: cannot take address of consteval function 'bad' outside of an immediate invocation
          call({}, bad);  // error: cannot take address of consteval function 'bad' outside of an immediate invocation
          return true;
      }
  };
  
  // 3
  template <typename T>
  struct Bar {
      static consteval void bad(int) {}
  
      static constexpr bool test() {
          bad(T::value);  // error: cannot take address of consteval function 'bad' outside of an immediate invocation
          return true;
      }
  };


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113859/new/

https://reviews.llvm.org/D113859



More information about the cfe-commits mailing list