leoetlino added a comment.

While this patch doesn't introduce new regressions and does fix compilation of 
the code snippet mentioned earlier, I'm not sure this is the correct approach, 
considering there are a bunch of other similar template-related consteval bugs 
that this patch does *not* fix:

  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;
      }
  };

The problem seems to be that the call/arguments are type dependent so nothing 
is added to `ImmediateInvocationCandidates` -- and so 
`HandleImmediateInvocations` (in SemaExpr.cpp) never removes anything from 
`ReferenceToConsteval` despite the references to the consteval functions being 
used for immediate invocations.

Another variant of the issue:

  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;
      }
  };

Not sure what the best way of fixing those issues would be -- any guidance 
would be greatly appreciated!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113859

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to