Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive template with hyperobject causes crash #222

Closed
VoxSciurorum opened this issue Dec 8, 2023 · 1 comment
Closed

Recursive template with hyperobject causes crash #222

VoxSciurorum opened this issue Dec 8, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@VoxSciurorum
Copy link
Contributor

This code:

#define DEPTH 3
template<int N> struct R {
  static void identity(void *);
  static void reduce(void *, void *);
  int get(int depth) { return depth <= 0 ? i : field.get(depth - 1); }
public:
  R<N - 1> field;
  int _Hyperobject(identity, reduce) i;
};

template<> struct R<0> { int field; int get(int) { return field; } };

extern R<DEPTH> r;

int f() { return r.get(DEPTH / 2); }

causes a compiler error:

clang/lib/AST/ExprConstant.cpp:15455: bool clang::Expr::isEvaluatable(const clang::ASTContext&, clang::Expr::SideEffectsKind) const: Assertion `!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed.
@VoxSciurorum VoxSciurorum added the bug Something isn't working label Dec 8, 2023
@VoxSciurorum VoxSciurorum self-assigned this Dec 8, 2023
@VoxSciurorum
Copy link
Contributor Author

BuildHyperobjectLookup is called on

MemberExpr 0x83bce5740 'int _Hyperobject(identity, reduce)' lvalue ->i 0x83bce51c0
`-CXXThisExpr 0x83bce5730 'struct R<3> *' implicit this

on which isValueDependent() returns false. The expansion into a hyperobject lookup has isValueDependent true because of the added references to the identity and reduce members. They may still be the generic versions instead of the R<3> versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants