office-gobmx/external/pdfium/constexpr-template.patch
Stephan Bergmann d1b867e42e external/pdfium: Address a constexpr template point of instantiation issue
...that hits at least when building with Clang and --with-latest-c++ against
recent libc++ or MSVC standard library (where C++20 and esp. C++23 made more and
more class template member functions constexpr).  My understanding is that there
is some leeway at what point a compiler should instantiate such function
specializations, and Clang decides to instantiate constexpr ones early (cf.
<242ad89a15>
"C++11 half of r147023: In C++11, additionally eagerly instantiate:" and its "Do
not defer instantiations of constexpr functions" comment, and the discussion at
<https://discourse.llvm.org/t/point-of-instantiation-of-constexpr-function-template/65129>).

> In file included from workdir/UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_SymbolDict.cpp:7:
> In file included from workdir/UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_SymbolDict.h:10:
> In file included from ~/llvm/inst/bin/../include/c++/v1/memory:881:
> In file included from ~/llvm/inst/bin/../include/c++/v1/__memory/shared_ptr.h:30:
> ~/llvm/inst/bin/../include/c++/v1/__memory/unique_ptr.h:47:19: error: invalid application of 'sizeof' to an incomplete type 'CJBig2_Image'
>     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
>                   ^~~~~~~~~~~
> ~/llvm/inst/bin/../include/c++/v1/__memory/unique_ptr.h:281:7: note: in instantiation of member function 'std::default_delete<CJBig2_Image>::operator()' requested here
>       __ptr_.second()(__tmp);
>       ^
> ~/llvm/inst/bin/../include/c++/v1/__memory/unique_ptr.h:247:75: note: in instantiation of member function 'std::unique_ptr<CJBig2_Image>::reset' requested here
>   _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
>                                                                           ^
> ~/llvm/inst/bin/../include/c++/v1/__memory/construct_at.h:64:13: note: in instantiation of member function 'std::unique_ptr<CJBig2_Image>::~unique_ptr' requested here
>     __loc->~_Tp();
>             ^
> ~/llvm/inst/bin/../include/c++/v1/__memory/construct_at.h:89:12: note: in instantiation of function template specialization 'std::__destroy_at<std::unique_ptr<CJBig2_Image>, 0>' requested here
>     _VSTD::__destroy_at(__loc);
>            ^
> ~/llvm/inst/bin/../include/c++/v1/__memory/allocator_traits.h:317:16: note: in instantiation of function template specialization 'std::destroy_at<std::unique_ptr<CJBig2_Image>, 0>' requested here
>         _VSTD::destroy_at(__p);
>                ^
> ~/llvm/inst/bin/../include/c++/v1/__split_buffer:304:25: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<std::unique_ptr<CJBig2_Image>>>::destroy<std::unique_ptr<CJBig2_Image>, void, void>' requested here
>         __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__end_));
>                         ^
> ~/llvm/inst/bin/../include/c++/v1/__split_buffer:145:10: note: in instantiation of member function 'std::__split_buffer<std::unique_ptr<CJBig2_Image>, std::allocator<std::unique_ptr<CJBig2_Image>> &>::__destruct_at_end' requested here
>         {__destruct_at_end(__new_last, false_type());}
>          ^
> ~/llvm/inst/bin/../include/c++/v1/__split_buffer:103:10: note: in instantiation of member function 'std::__split_buffer<std::unique_ptr<CJBig2_Image>, std::allocator<std::unique_ptr<CJBig2_Image>> &>::__destruct_at_end' requested here
>         {__destruct_at_end(__begin_);}
>          ^
> ~/llvm/inst/bin/../include/c++/v1/__split_buffer:361:5: note: in instantiation of member function 'std::__split_buffer<std::unique_ptr<CJBig2_Image>, std::allocator<std::unique_ptr<CJBig2_Image>> &>::clear' requested here
>     clear();
>     ^
> ~/llvm/inst/bin/../include/c++/v1/vector:1536:49: note: in instantiation of member function 'std::__split_buffer<std::unique_ptr<CJBig2_Image>, std::allocator<std::unique_ptr<CJBig2_Image>> &>::~__split_buffer' requested here
>     __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
>                                                 ^
> ~/llvm/inst/bin/../include/c++/v1/vector:1568:9: note: in instantiation of function template specialization 'std::vector<std::unique_ptr<CJBig2_Image>>::__push_back_slow_path<std::unique_ptr<CJBig2_Image>>' requested here
>         __push_back_slow_path(std::move(__x));
>         ^
> workdir/UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_SymbolDict.h:26:16: note: in instantiation of member function 'std::vector<std::unique_ptr<CJBig2_Image>>::push_back' requested here
>     m_SDEXSYMS.push_back(std::move(image));
>                ^
> workdir/UnpackedTarball/pdfium/core/fxcodec/jbig2/JBig2_SymbolDict.h:16:7: note: forward declaration of 'CJBig2_Image'
> class CJBig2_Image;
>       ^

Change-Id: Ibaeb72eefdd58ca39ffa6bb8f6c5d7088ce51ab7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141812
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-25 16:22:30 +02:00

12 lines
282 B
Diff

--- core/fxcodec/jbig2/JBig2_SymbolDict.h
+++ core/fxcodec/jbig2/JBig2_SymbolDict.h
@@ -12,8 +12,7 @@
#include <vector>
#include "core/fxcodec/jbig2/JBig2_ArithDecoder.h"
-
-class CJBig2_Image;
+#include "core/fxcodec/jbig2/JBig2_Image.h"
class CJBig2_SymbolDict {
public: