From a9bba7faa067a4ff6a3167d92531e5163ffff4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Mon, 28 Nov 2022 22:35:05 +0700 Subject: [PATCH] source-highlight: patch for gcc-12 --- srcpkgs/source-highlight/patches/gcc-12.patch | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 srcpkgs/source-highlight/patches/gcc-12.patch diff --git a/srcpkgs/source-highlight/patches/gcc-12.patch b/srcpkgs/source-highlight/patches/gcc-12.patch new file mode 100644 index 00000000000..6ee46e8beed --- /dev/null +++ b/srcpkgs/source-highlight/patches/gcc-12.patch @@ -0,0 +1,81 @@ +From ab9fe5cb9b85c5afab94f2a7f4b6d7d473c14ee9 Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Mon, 8 Nov 2021 23:30:42 +0000 +Subject: Fix tests build failure on clang and gcc-12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Both gcc-12 and clang can't find ostream<<(..., std::pair<...>) +overload when compile lib/tests/test_wordtokenizer_main.cpp and +fail as: + + ./../srchilite/tostringcollection.h:103:9: + error no match for «operator<<» (operand types are «std::ostringstream» + {aka «std::__cxx11::basic_ostringstream»} + and «const std::pair, + std::__cxx11::basic_string >») + 103 | buf << (*it); + | ~~~~^~~~~~~~ + +We fix it by placing overload to std namespace where std::pair<...> +is defined to make ADL work predictably. + +clang also has a trouble compiling lib/tests/stdboosterror.h as: + + ./stdboosterror.h:7:72: error: parameter declarator cannot be qualified + std_boost_exception(boost::regex_error(boost::regex_constants::error_bad_pattern)); + ~~~~~~~~~~~~~~~~~~~~~~~~^ + +gcc compiles it by accident: https://gcc.gnu.org/PR86564 + +Let's disambiguate syntax by making it an explicit constructor call. +--- + lib/tests/stdboosterror.h | 2 +- + lib/tests/test_wordtokenizer_main.cpp | 10 ++++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/lib/tests/stdboosterror.h b/lib/tests/stdboosterror.h +index 568545b..d59bfa6 100644 +--- a/lib/tests/stdboosterror.h ++++ b/lib/tests/stdboosterror.h +@@ -4,7 +4,7 @@ + #include + + static boost::regex_error +- std_boost_exception(boost::regex_error(boost::regex_constants::error_bad_pattern)); ++ std_boost_exception = boost::regex_error(boost::regex_constants::error_bad_pattern); + + /** + * returns the string representing a standard exception (which +diff --git a/lib/tests/test_wordtokenizer_main.cpp b/lib/tests/test_wordtokenizer_main.cpp +index 40e23b1..11ba389 100644 +--- a/lib/tests/test_wordtokenizer_main.cpp ++++ b/lib/tests/test_wordtokenizer_main.cpp +@@ -11,6 +11,14 @@ + using namespace std; + using namespace srchilite; + ++/* ++ * We have to use 'std' namespaces because 'WordTokenizer::WordTokenizerResults::value_type' ++ * is an std::pair in disguise. We have to place 'operator<<()' ++ * into the same namespace for ADL to work. Otherwise gcc-12 or clang-13 can't find the ++ * overload. ++ */ ++namespace std { ++ + static ostream &operator <<(ostream &os, const WordTokenizer::WordTokenizerResults::value_type &); + + ostream &operator <<(ostream &os, const WordTokenizer::WordTokenizerResults::value_type &token) { +@@ -23,6 +31,8 @@ ostream &operator <<(ostream &os, const WordTokenizer::WordTokenizerResults::val + return os; + } + ++} ++ + int main() { + WordTokenizer::WordTokenizerResults tokens; + +-- +cgit v1.1 +