Files
Chris Peterson 78cb174eb3 Bug 2069687 - intl: Move the Encoder and Decoder factory methods out of the Encoding class definition for C++23 compatibility. r=hsivonen
C++23 P2448R2 [1] relaxed the requirements for constexpr destructors.
In C++23, Clang makes UniquePtr's destructor automatically constexpr.
Clang eagerly instantiates its body for the local UniquePtr<Encoder>
and UniquePtr<Decoder> variables in Encoding's inline factory methods.
Encoder and Decoder are only forward-declared at that point, so the
deleter's complete-type check fails.

To resolve this, move the NewDecoder() and NewDecoder factory methods
after the Encoding class definition so they have complete class
definitions for Encoder and Decoder.

[1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2448r2.html

MacOSX26.1.sdk/usr/include/c++/v1/__memory/unique_ptr.h:76:19: error: invalid application of 'sizeof' to an incomplete type 'mozilla::Encoder'
76 |     static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
   |                   ^~~~~~~~~~~
MacOSX26.1.sdk/usr/include/c++/v1/__memory/unique_ptr.h:300:7: note: in instantiation of member function 'std::default_delete<mozilla::Encoder>::operator()' requested here
300 |       __deleter_(__tmp);
    |       ^
MacOSX26.1.sdk/usr/include/c++/v1/__memory/unique_ptr.h:269:71: note: in instantiation of member function 'std::unique_ptr<mozilla::Encoder>::reset' requested here
269 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
    |                                                                       ^
obj-aarch64-apple-darwin25.0.0/dist/include/mozilla/Encoding.h:736:24: note: in instantiation of member function 'std::unique_ptr<mozilla::Encoder>::~unique_ptr' requested here
736 |     UniquePtr<Encoder> encoder(encoding_new_encoder(this));
    |                        ^
obj-aarch64-apple-darwin25.0.0/dist/include/mozilla/Encoding.h:28:7: note: forward declaration of 'mozilla::Encoder'
 28 | class Encoder;
    |       ^

Differential Revision: https://phabricator.services.mozilla.com/D323890
2026-09-11 07:20:26 +00:00
..