From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 546F5385801F; Tue, 18 Jan 2022 11:40:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 546F5385801F From: "jwakely.gcc at gmail dot com" To: systemtap@sourceware.org Subject: [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas Date: Tue, 18 Jan 2022 11:40:27 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: systemtap X-Bugzilla-Component: dyninst X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jwakely.gcc at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: systemtap at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: systemtap@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Systemtap mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 11:40:27 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28790 Bug ID: 28790 Summary: Replace deprecated C++98 junk with lambdas Product: systemtap Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: dyninst Assignee: systemtap at sourceware dot org Reporter: jwakely.gcc at gmail dot com Target Milestone: --- I have no idea what the correct Component is, sorry. GCC 12 now (rightly) warns about systemtap's use of std::ptr_fun util.cxx: In function 'void ltrim(std::string&)': util.cxx:1764:56: error: 'std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg)) [with _Arg =3D int; _Result =3D int]' is deprecated: use 'std::mem_fn' instead [-Werror=3Ddeprecated-declarations] 1764 | std::not1(std::ptr_fun(std::isspace)))); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~= ~~ In file included from /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/s= tring:48, from util.h:8, from util.cxx:17: /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/b= its/stl_function.h:1126:5: note: declared here 1126 | ptr_fun(_Result (*__x)(_Arg)) | ^~~~~~~ util.cxx:1764:33: error: 'constexpr std::unary_negate<_Predicate> std::not1(const _Predicate&) [with _Predicate =3D pointer_to_unary_function= ]' is deprecated: use 'std::not_fn' instead [-Werror=3Ddeprecated-declarations] 1764 | std::not1(std::ptr_fun(std::isspace)))); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ In file included from /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/s= tring:48, from util.h:8, from util.cxx:17: /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/b= its/stl_function.h:1046:5: note: declared here 1046 | not1(const _Predicate& __pred) | ^~~~ util.cxx: In function 'void rtrim(std::string&)': util.cxx:1772:43: error: 'std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg)) [with _Arg =3D int; _Result =3D int]' is deprecated: use 'std::mem_fn' instead [-Werror=3Ddeprecated-declarations] 1772 | std::not1(std::ptr_fun(std::isspace))).base(), s.end()); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ In file included from /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/s= tring:48, from util.h:8, from util.cxx:17: /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/b= its/stl_function.h:1126:5: note: declared here 1126 | ptr_fun(_Result (*__x)(_Arg)) | ^~~~~~~ util.cxx:1772:20: error: 'constexpr std::unary_negate<_Predicate> std::not1(const _Predicate&) [with _Predicate =3D pointer_to_unary_function= ]' is deprecated: use 'std::not_fn' instead [-Werror=3Ddeprecated-declarations] 1772 | std::not1(std::ptr_fun(std::isspace))).base(), s.end()); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/s= tring:48, from util.h:8, from util.cxx:17: /nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/b= its/stl_function.h:1046:5: note: declared here 1046 | not1(const _Predicate& __pred) | ^~~~ cc1plus: all warnings being treated as errors std::ptr_fun has not been part of the C++ standard since C++17, so you shou= ld avoid using it (or ensure you compile as C++14). The code is wrong for platforms with signed char anyway, with potentially undefined behaviour. The argument to std::isspace(int) must have the value = of an unsigned char, i.e. it must be between (int)0 and (int)255. If you call = it with a signed char that has a negative value, you get a negative int, which= is outside the allowed range. You can kill two birds with one stone by just getting rid of the std::ptr_f= un uses entirely: diff --git a/util.cxx b/util.cxx index c20f76003..76c751f18 100644 --- a/util.cxx +++ b/util.cxx @@ -1763,7 +1763,7 @@ ltrim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), - std::not1(std::ptr_fun(std::isspace)))); + [](unsigned char c) { return !std::isspace(c); })); } // trim from end (in place) @@ -1771,7 +1771,7 @@ void rtrim(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), - std::not1(std::ptr_fun(std::isspace))).base(), s.end()); + [](unsigned char c) { return !std::isspace(c); }).base(), s.end()= ); } // trim from both ends (in place) --=20 You are receiving this mail because: You are the assignee for the bug.=