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

Struct with non-POD fields can be improperly constructed from Rust #23

Closed
dtolnay opened this issue Oct 11, 2020 · 2 comments · Fixed by #25
Closed

Struct with non-POD fields can be improperly constructed from Rust #23

dtolnay opened this issue Oct 11, 2020 · 2 comments · Fixed by #25

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Oct 11, 2020

// src/input.h

#pragma once
#include <string>
struct T {
  std::string s;
};
void f(const T& t);
// src/input.cc

#include "input.h"
#include <iostream>

void f(const T& t) {
  std::cout << t.s << std::endl;
}
// src/main.rs

use autocxx::include_cxx;

include_cxx!(Header("input.h"), Allow("T"), Allow("f"));

fn main() {
    ffi::cxxbridge::f(&ffi::cxxbridge::T {});
}
$  cargo run
Segmentation fault (core dumped)
@adetaylor
Copy link
Collaborator

Hmmm. Yep. That's going to be tougher to figure out.

@adetaylor
Copy link
Collaborator

I'd love to think that this will be as simple as putting in a private field, but I have a feeling this one is going to be more icky.

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 a pull request may close this issue.

2 participants