Skip to content

Conversation

lkeegan
Copy link
Member

@lkeegan lkeegan commented Nov 29, 2023

  • this implicity disables the LLVMVisitor copy constructors
    • avoids segfault that occured if an initialized LLVMVisitor is copy assigned to
    • (segfault itself looks like it may be a bug in LLVM)
  • define default constructor/destructor in cpp file to avoid "incomplete type" compilation error
  • resolves LLVMVisitor assignment constructor after init segfaults #1994

…`llvm::ExecutionEngine`

- this implicity disables the `LLVMVisitor` copy constructors
  - avoids segfault that occured if an initialized `LLVMVisitor` is copy assigned to
  - (segfault itself looks like it may be a bug in LLVM)
- define default constructor/destructor in cpp file to avoid "incomplete type" compilation error
- resolves symengine#1994
Copy link
Contributor

@rikardn rikardn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels as the right thing to do since the visitor has unique ownership of the context.

@bjodah
Copy link
Contributor

bjodah commented Nov 29, 2023

Looks good!

Should we include the test case you wrote as well? something like this:

TEST_CASE("LLVMDoubleVisitor assignment constructor after init",
          "[llvm_double]")
{
    RCP<const Basic> x, y, r;
    x = symbol("x");
    y = symbol("y");
    r = add(x, pow(x, y));
    LLVMDoubleVisitor v1;
    v1.init({x, y}, *r);
    if constexpr (std::is_copy_constructible<LLVMDoubleVisitor>::value) {
        LLVMDoubleVisitor v2;
        v1 = v2;
    }
}

(untested). But maybe it's overkill. I'm +1 to merging as is as well.

@lkeegan
Copy link
Member Author

lkeegan commented Nov 29, 2023

Looks good!

Should we include the test case you wrote as well? something like this:

TEST_CASE("LLVMDoubleVisitor assignment constructor after init",
          "[llvm_double]")
{
    RCP<const Basic> x, y, r;
    x = symbol("x");
    y = symbol("y");
    r = add(x, pow(x, y));
    LLVMDoubleVisitor v1;
    v1.init({x, y}, *r);
    if constexpr (std::is_copy_constructible<LLVMDoubleVisitor>::value) {
        LLVMDoubleVisitor v2;
        v1 = v2;
    }
}

(untested). But maybe it's overkill. I'm +1 to merging as is as well.

I like the idea, but I think symengine only requires c++11 and this I guess needs c++17?

@bjodah
Copy link
Contributor

bjodah commented Nov 29, 2023

Ah, yes you're right.

@bjodah bjodah merged commit bbaed47 into symengine:master Dec 24, 2023
@bjodah
Copy link
Contributor

bjodah commented Dec 24, 2023

Let's get this in. Merry Christmas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLVMVisitor assignment constructor after init segfaults
3 participants