sw/source/ui/dialog/ascfldlg.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
New commits: commit b3bc93de3115994bb71e0be2700504db967482e0 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Aug 16 21:45:13 2022 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Aug 17 08:10:13 2022 +0200 Fix undefined behavior for good (Where the range of values of LineEnd is [0, 2], see include/tools/lineend.hxx.) 7786bafdb8951aa3f0acda801ddb3704c81d00d8 "workaround -Wenum-constexpr-conversion" had silenced the (unintended, see below) warning about undefined behavior when eEnd was compared against LineEnd(-1), but failed to address the undefined behavior when eEnd was initialized with LineEnd(-1). (On Clang 16 trunk, the original <https://github.com/llvm/llvm-project/commit/b3645353041818f61e2580635409ddb81ff5a272> "[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values" only emitted diagnostics in constant evaluation contexts, then <https://github.com/llvm/llvm-project/commit/cc104113ddecbdcec2cca848adbb6afa1214e9de> "[Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values" accidentally extended that to other contexts, so caused the unintended warning here, and finally <https://github.com/llvm/llvm-project/commit/4e458765aaef7988e687e190d865f331727825c0> "[Clang] Restrict non fixed enum to a value outside the range of the enumeration values warning to context requiring a constant expression" fixed that mistake and made the unintended warning go away again.) Change-Id: I44c14ed9c9455d05d80baddcb63be97d0bfb0278 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138385 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index 036159ec1aaa..6975cc72df8c 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <optional> #include <utility> #include <hintids.hxx> @@ -364,7 +365,8 @@ void SwAsciiFilterDlg::UpdateIncludeBOMSensitiveState() IMPL_LINK_NOARG(SwAsciiFilterDlg, CharSetSelHdl, weld::ComboBox&, void) { - LineEnd eOldEnd = GetCRLF(), eEnd = LineEnd(-1); + LineEnd eOldEnd = GetCRLF(); + std::optional<LineEnd> eEnd; LanguageType nLng = m_xFontLB->get_visible() ? m_xLanguageLB->get_active_id() : LANGUAGE_SYSTEM, @@ -418,10 +420,10 @@ IMPL_LINK_NOARG(SwAsciiFilterDlg, CharSetSelHdl, weld::ComboBox&, void) } m_bSaveLineStatus = false; - if( static_cast<int>(eEnd) != -1 ) // changed? + if( eEnd ) // changed? { - if( eOldEnd != eEnd ) - SetCRLF( eEnd ); + if( eOldEnd != *eEnd ) + SetCRLF( *eEnd ); } else {