git: e8b22e75d759 - main - math/openfst-vosk: fix build with clang and libc++ 19

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 03 Nov 2024 20:53:36 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e8b22e75d75924f1f6567044252abe2a3d60078e

commit e8b22e75d75924f1f6567044252abe2a3d60078e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-11-03 11:47:38 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-11-03 20:53:19 +0000

    math/openfst-vosk: fix build with clang and libc++ 19
    
    With clang and libc++ 19 math/openfst-vosk fails to compile, with errors
    similar to:
    
      ./../include/fst/fst.h:704:15: error: no viable overloaded '='
        704 |     isymbols_ = impl.isymbols_ ? impl.isymbols_->Copy() : nullptr;
            |     ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/include/c++/v1/__memory/unique_ptr.h:231:67: note: candidate function not viable: no known conversion from 'SymbolTable *' to 'unique_ptr<SymbolTable>' for 1st argument
        231 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
            |                                                                   ^         ~~~~~~~~~~~~~~~~
      /usr/include/c++/v1/__memory/unique_ptr.h:241:67: note: candidate template ignored: could not match 'unique_ptr<_Up, _Ep>' against 'SymbolTable *'
        241 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
            |                                                                   ^
      /usr/include/c++/v1/__memory/unique_ptr.h:263:67: note: candidate function not viable: no known conversion from 'SymbolTable *' to 'nullptr_t' (aka 'std::nullptr_t') for 1st argument
        263 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
            |                                                                   ^         ~~~~~~~~~
      /usr/include/c++/v1/__memory/unique_ptr.h:138:59: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'SymbolTable *' to 'const unique_ptr<SymbolTable>' for 1st argument
        138 | class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
            |                                                           ^~~~~~~~~~
    
    and:
    
      ./../include/fst/bi-table.h:330:25: error: no member named 's_' in 'VectorHashBiTable<I, T, S, FP, H, HS>'
        330 |       : selector_(table.s_),
            |                   ~~~~~ ^
    
    The first error can be fixed by using `std::unique_ptr<>::reset` instead
    of the assignment operator. The second error can be fixed by using the
    correct class member, `selector_`.
    
    PR:             282513
    Approved by:    yuri (maintainer)
    MFH:            2024Q3
---
 math/openfst-vosk/files/patch-src_include_fst_bi-table.h | 11 +++++++++++
 math/openfst-vosk/files/patch-src_include_fst_fst.h      | 13 +++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/math/openfst-vosk/files/patch-src_include_fst_bi-table.h b/math/openfst-vosk/files/patch-src_include_fst_bi-table.h
new file mode 100644
index 000000000000..b6b8a0a22c26
--- /dev/null
+++ b/math/openfst-vosk/files/patch-src_include_fst_bi-table.h
@@ -0,0 +1,11 @@
+--- src/include/fst/bi-table.h.orig	2021-02-07 08:38:45 UTC
++++ src/include/fst/bi-table.h
+@@ -327,7 +327,7 @@ class VectorHashBiTable {
+   }
+ 
+   VectorHashBiTable(const VectorHashBiTable<I, T, S, FP, H, HS> &table)
+-      : selector_(table.s_),
++      : selector_(table.selector_),
+         fp_(table.fp_),
+         h_(table.h_),
+         id2entry_(table.id2entry_),
diff --git a/math/openfst-vosk/files/patch-src_include_fst_fst.h b/math/openfst-vosk/files/patch-src_include_fst_fst.h
new file mode 100644
index 000000000000..ee516a070325
--- /dev/null
+++ b/math/openfst-vosk/files/patch-src_include_fst_fst.h
@@ -0,0 +1,13 @@
+--- src/include/fst/fst.h.orig	2021-02-07 08:38:45 UTC
++++ src/include/fst/fst.h
+@@ -701,8 +701,8 @@ class FstImpl {
+     properties_.store(impl.properties_.load(std::memory_order_relaxed),
+                       std::memory_order_relaxed);
+     type_ = impl.type_;
+-    isymbols_ = impl.isymbols_ ? impl.isymbols_->Copy() : nullptr;
+-    osymbols_ = impl.osymbols_ ? impl.osymbols_->Copy() : nullptr;
++    isymbols_.reset(impl.isymbols_ ? impl.isymbols_->Copy() : nullptr);
++    osymbols_.reset(impl.osymbols_ ? impl.osymbols_->Copy() : nullptr);
+     return *this;
+   }
+