[PATCH] D111669: No longer crash when a consteval function returns a structure

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 26 16:31:53 PDT 2021


rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

Hmm.  Generally these cases are expected to handle the situation where there's no result slot passed in, which currently isn't exclusive to an ignored result (although you could argue it should be).  IIRC we usually don't pass in a slot when evaluating an expression of agg type as anything except an initializer, e.g. when evaluating the `E` in `E.member`.  The general fix is to call `EnsureDest` before accessing `Dest`.  The only reason we wouldn't need to do that is if `ConstantExpr` is restricted in where it can appear such that that's impossible.

Skipping an unnecessary initialization does sound like a good optimization in general, but that's on top of the bug fix, not an alternative.

Separately, seeing this code makes me worried that it doesn't support the full set of constant initialization.  We do have some kinds of constant initialization that can't be emitted as abstract initializers, e.g. address-diversified pointer auth.  But we can deal with that as a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111669



More information about the cfe-commits mailing list