Closed
Description
I'm generating extern "C"
functions using macros. Since it's currently not possible to use $concat_ident
for function names, I can't give these functions unique names.
I was hoping for rust's name mangling to take care of the issue; but unfortunately this doesn't work if the macro is used twice in the same function. This usually results in internal compiler errors for me, but on the playpen machine it's possible to produce undefined behavior in safe code:
fn main() {
{
extern "C" fn test(a: &mut i32) {
println!("a: {:?}", a);
*a = 1;
}
}
{
extern "C" fn test(b: &i32) {
println!("b: {:?}", b);
}
test(&1);
}
}
Expected output: b: 1
Actual output: a: 1
playpen: application terminated abnormally with signal 4 (Illegal instruction)