From c509ef12acd198ffdde2af02148002257b60912a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 30 Jan 2021 09:33:17 -0500 Subject: [PATCH] Add failing regression test for #1973. --- bindgen-integration/cpp/Test.cc | 9 +++++++++ bindgen-integration/cpp/Test.h | 6 ++++++ bindgen-integration/src/lib.rs | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/bindgen-integration/cpp/Test.cc b/bindgen-integration/cpp/Test.cc index 240109bb..71a0a4b9 100644 --- a/bindgen-integration/cpp/Test.cc +++ b/bindgen-integration/cpp/Test.cc @@ -135,3 +135,12 @@ Seventh::assert(bool first, int my_prefixed_function_name() { return 4; } + +Coord coord(double x, double y, double z, double t) { + Coord res; + res.v[0] = x; + res.v[1] = y; + res.v[2] = z; + res.v[3] = t; + return res; +} diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h index 7605d9f0..51a6e4b8 100644 --- a/bindgen-integration/cpp/Test.h +++ b/bindgen-integration/cpp/Test.h @@ -226,3 +226,9 @@ struct my_prefixed_templated_foo { my_prefixed_templated_foo TEMPLATED_CONST_VALUE; void my_prefixed_function_to_remove(); + +typedef union { + double v[4]; +} Coord; + +Coord coord(double x, double y, double z, double t); diff --git a/bindgen-integration/src/lib.rs b/bindgen-integration/src/lib.rs index 088e8083..c145d895 100755 --- a/bindgen-integration/src/lib.rs +++ b/bindgen-integration/src/lib.rs @@ -259,3 +259,12 @@ fn test_macro_customintkind_path() { let v: &std::any::Any = &bindings::TESTMACRO_CUSTOMINTKIND_PATH; assert!(v.is::()) } + +// https://github.com/rust-lang/rust-bindgen/issues/1973 +#[test] +fn test_homogeneous_aggregate_float_union() { + unsafe { + let coord = &bindings::coord(1., 2., 3., 4.); + assert_eq!([1., 2., 3., 4.], coord.v) + } +}