Skip to content

reloc and constexpr #28

Description

@SebastienBini

The paper never mentions how reloc and constexpr work together. Namely:

  • can reloc be used in a constexpr?
  • can the relocation constructor be constexpr?
  • can the relocation assign operator be constexpr?
  • can a decomposing function be constexpr?

The only thing that gets me slightly worried is the eliding ABI trick. On caller-destroy ABI, we propose to emit two functions (eliding and classic) for the reloc assign operator and decomposing functions.
The classic function is caller-destroy and will call the eliding one which is callee-destroy, using the following trick:

f.classic(T value)
{
  union { T __tmp } = { .__tmp = reloc value /* move or copy construct */ };
  f.eliding(&__tmp);
}

I don't know to what extent the union trick is compliant w/t constexpr, nor if it even matters as this is part of compiler-generated code.

Also, in the case of a trivially relocatable type, reloc x will likely get optimized into a single memcpy call. This paper legalizes this optimization, but I believe we must clearly write it down in the context of constexpr.

Do you foresee any other issues? What's your take on this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions