From: Pierre-Emmanuel Patry <[email protected]>

gcc/rust/ChangeLog:

        * ast/rust-type.h: Prevent reconstruction on null pointers.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
 gcc/rust/ast/rust-type.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/ast/rust-type.h b/gcc/rust/ast/rust-type.h
index f2502d74501..8d6c3e5166f 100644
--- a/gcc/rust/ast/rust-type.h
+++ b/gcc/rust/ast/rust-type.h
@@ -1048,10 +1048,14 @@ public:
 
   BareFunctionType *reconstruct_impl () const override
   {
+    std::unique_ptr<TypeNoBounds> ret_type = nullptr;
+    if (return_type != nullptr)
+      ret_type = return_type->reconstruct ();
+
     return new BareFunctionType (
       for_lifetimes, function_qualifiers, params,
       /* FIXME: Should params be reconstruct() as well? */
-      _is_variadic, variadic_attrs, return_type->reconstruct (), locus);
+      _is_variadic, variadic_attrs, std::move (ret_type), locus);
   }
 
 protected:
-- 
2.50.1

Reply via email to