* [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas
@ 2022-01-18 11:40 jwakely.gcc at gmail dot com
2022-01-18 11:41 ` [Bug dyninst/28790] " jwakely.gcc at gmail dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: jwakely.gcc at gmail dot com @ 2022-01-18 11:40 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
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 = int; _Result = int]' is
deprecated: use 'std::mem_fn' instead [-Werror=deprecated-declarations]
1764 | std::not1(std::ptr_fun<int,
int>(std::isspace))));
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/string:48,
from util.h:8,
from util.cxx:17:
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/bits/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 = pointer_to_unary_function<int,
int>]' is deprecated: use 'std::not_fn' instead
[-Werror=deprecated-declarations]
1764 | std::not1(std::ptr_fun<int,
int>(std::isspace))));
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/string:48,
from util.h:8,
from util.cxx:17:
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/bits/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 = int; _Result = int]' is
deprecated: use 'std::mem_fn' instead [-Werror=deprecated-declarations]
1772 | std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
s.end());
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/string:48,
from util.h:8,
from util.cxx:17:
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/bits/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 = pointer_to_unary_function<int,
int>]' is deprecated: use 'std::not_fn' instead
[-Werror=deprecated-declarations]
1772 | std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
s.end());
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/string:48,
from util.h:8,
from util.cxx:17:
/nix/store/w4d0lkjirdzr19cqdq428j0kqlzc4lgd-gcc-12.0.0/include/c++/12.0.0/bits/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 should
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_fun
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<int, int>(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<int, int>(std::isspace))).base(), s.end());
+ [](unsigned char c) { return !std::isspace(c); }).base(), s.end());
}
// trim from both ends (in place)
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
@ 2022-01-18 11:41 ` jwakely.gcc at gmail dot com
2022-01-18 21:02 ` fche at redhat dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jwakely.gcc at gmail dot com @ 2022-01-18 11:41 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
--- Comment #1 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
N.B. the use of unsigned char as the lambda argument converts the incoming char
to unsigned char, avoiding the UB.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
2022-01-18 11:41 ` [Bug dyninst/28790] " jwakely.gcc at gmail dot com
@ 2022-01-18 21:02 ` fche at redhat dot com
2022-01-24 18:59 ` me at serhei dot io
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fche at redhat dot com @ 2022-01-18 21:02 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
Frank Ch. Eigler <fche at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fche at redhat dot com
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Frank Ch. Eigler <fche at redhat dot com> ---
Thanks, merged!
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
2022-01-18 11:41 ` [Bug dyninst/28790] " jwakely.gcc at gmail dot com
2022-01-18 21:02 ` fche at redhat dot com
@ 2022-01-24 18:59 ` me at serhei dot io
2022-01-24 22:45 ` jwakely.gcc at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: me at serhei dot io @ 2022-01-24 18:59 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
Serhei Makarov <me at serhei dot io> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |me at serhei dot io
--- Comment #3 from Serhei Makarov <me at serhei dot io> ---
Note that commit f199d19 replaces the lambdas with a named function ptr
Someday we might want to give up building on older systems to use latest C++
features, but saving a couple of lines in ltrim()/rtrim() is probably not
sufficient reason to do it. stap continues to build just fine with this simple
tweak.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
` (2 preceding siblings ...)
2022-01-24 18:59 ` me at serhei dot io
@ 2022-01-24 22:45 ` jwakely.gcc at gmail dot com
2022-01-24 22:47 ` jwakely.gcc at gmail dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jwakely.gcc at gmail dot com @ 2022-01-24 22:45 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
--- Comment #4 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
My patch uses nothing newer than C++11, which is already required for building
GDB isn't?
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
` (3 preceding siblings ...)
2022-01-24 22:45 ` jwakely.gcc at gmail dot com
@ 2022-01-24 22:47 ` jwakely.gcc at gmail dot com
2022-01-24 23:22 ` me at serhei dot io
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jwakely.gcc at gmail dot com @ 2022-01-24 22:47 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
--- Comment #5 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
Doh sorry, this wasn't a GDB bug! brainfart
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
` (4 preceding siblings ...)
2022-01-24 22:47 ` jwakely.gcc at gmail dot com
@ 2022-01-24 23:22 ` me at serhei dot io
2022-01-24 23:30 ` jwakely.gcc at gmail dot com
2022-01-24 23:33 ` me at serhei dot io
7 siblings, 0 replies; 9+ messages in thread
From: me at serhei dot io @ 2022-01-24 23:22 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
--- Comment #6 from Serhei Makarov <me at serhei dot io> ---
The lambdas were unsupported on a buildbot compiling stap with gcc 4.4.7 (rhel6
system compiler; I know). Since the codebase compiled just fine otherwise & the
fix was simple, from an upstream PoV I didn't see rtrim() as a sufficient
reason to deprecate this configuration.
If it was a complex piece of code that depends on lambdas as a simplifying
abstraction, and avoiding them would multiply the complexity, I'd probably make
the call otherwise.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
` (5 preceding siblings ...)
2022-01-24 23:22 ` me at serhei dot io
@ 2022-01-24 23:30 ` jwakely.gcc at gmail dot com
2022-01-24 23:33 ` me at serhei dot io
7 siblings, 0 replies; 9+ messages in thread
From: jwakely.gcc at gmail dot com @ 2022-01-24 23:30 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
--- Comment #7 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
Makes perfect sense. The fact the two functions are right next to each other
and a named function can be defined immediately before them makes it an even
easier choice.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug dyninst/28790] Replace deprecated C++98 junk with lambdas
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
` (6 preceding siblings ...)
2022-01-24 23:30 ` jwakely.gcc at gmail dot com
@ 2022-01-24 23:33 ` me at serhei dot io
7 siblings, 0 replies; 9+ messages in thread
From: me at serhei dot io @ 2022-01-24 23:33 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=28790
--- Comment #8 from Serhei Makarov <me at serhei dot io> ---
Ah, I misunderstood the import of your earlier comment and that it applies to
the GDB codebase in particular.
It does make me wonder when/if stap will have a feature that depends on C++11
features in a serious way....
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-01-24 23:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 11:40 [Bug dyninst/28790] New: Replace deprecated C++98 junk with lambdas jwakely.gcc at gmail dot com
2022-01-18 11:41 ` [Bug dyninst/28790] " jwakely.gcc at gmail dot com
2022-01-18 21:02 ` fche at redhat dot com
2022-01-24 18:59 ` me at serhei dot io
2022-01-24 22:45 ` jwakely.gcc at gmail dot com
2022-01-24 22:47 ` jwakely.gcc at gmail dot com
2022-01-24 23:22 ` me at serhei dot io
2022-01-24 23:30 ` jwakely.gcc at gmail dot com
2022-01-24 23:33 ` me at serhei dot io
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).