Skip to content

fix: ST_Distance_Sphere::BindData::Copy std::move for GCC 11+#795

Open
pierre-warnier wants to merge 1 commit intoduckdb:v1.5-variegatafrom
pierre-warnier:pr/knn-0-build-fix
Open

fix: ST_Distance_Sphere::BindData::Copy std::move for GCC 11+#795
pierre-warnier wants to merge 1 commit intoduckdb:v1.5-variegatafrom
pierre-warnier:pr/knn-0-build-fix

Conversation

@pierre-warnier
Copy link
Copy Markdown

ST_Distance_Sphere::BindData::Copy() returns unique_ptr<FunctionData>, but constructs unique_ptr<BindData> internally. Returning copy directly relies on an implicit derived-to-base unique_ptr conversion that newer GCC (11+) rejects in a return statement without an explicit std::move:

error: could not convert 'copy' from
  'unique_ptr<duckdb::{anonymous}::ST_Distance_Sphere::BindData, ...>'
  to 'unique_ptr<duckdb::FunctionData, ...>'

The fix is a one-line change wrapping the return in std::move().

Diff

 unique_ptr<FunctionData> Copy() const override {
     auto copy = make_uniq<BindData>();
     copy->always_xy = always_xy;
-    return copy;
+    return std::move(copy);
 }

Scope

  • 1 file changed, 1 insertion, 1 deletion
  • No behavior change — purely a compilation fix
  • Unblocks building on Ubuntu 22.04 / Debian 12 (GCC 11+) out of the box

Verification

  • Built on GCC 11.4.0 (Ubuntu 22.04), no warnings
  • All existing spatial tests pass (test/sql/join/*, test/sql/geometry/*, test/sql/geos/*)

The Copy() method returns a unique_ptr<BindData> which must be
converted to unique_ptr<FunctionData>. Under GCC 11+ this
conversion requires explicit std::move() — newer compilers
reject the implicit conversion as a copy-initialization.

Fixes: error: could not convert 'copy' from
'unique_ptr<ST_Distance_Sphere::BindData>' to 'unique_ptr<FunctionData>'
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a GCC 11+ compilation error in the spatial extension by making the unique_ptr<BindData>unique_ptr<FunctionData> return conversion explicit in ST_Distance_Sphere::BindData::Copy().

Changes:

  • Update ST_Distance_Sphere::BindData::Copy() to return std::move(copy); so the converting move constructor for unique_ptr is used.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants