Bug 1541688
Summary: | Compiling stl::set compare on GCC 8.0 causes error | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | R4SAS <r4sas> |
Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED UPSTREAM | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | aoliva, davejohansen, fweimer, jakub, jwakely, law, mpolacek |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-02-05 02:15:41 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
R4SAS
2018-02-04 01:30:05 UTC
The problem is that the InboundTunnel and OutboundTunnel types are incomplete, so it's not possible to verify that the comparison function is valid. That code is very inefficient, as it will create new temporary shared_ptr objects for every comparison in the sets, requiring four atomic reference count updates for every comparison. Making the comparison function accept the derived types would avoid that, and fix the compilation error too: struct TunnelCreationTimeCmp { template<typename T> bool operator() (const std::shared_ptr<T>& t1, const std::shared_ptr<T>& t2) const { if (t1->GetCreationTime () != t2->GetCreationTime ()) return t1->GetCreationTime () > t2->GetCreationTime (); else return t1 < t2; } }; --- a/libi2pd/TunnelBase.h +++ b/libi2pd/TunnelBase.h @@ -59,7 +59,8 @@ namespace tunnel struct TunnelCreationTimeCmp { - bool operator() (const std::shared_ptr<const TunnelBase> & t1, const std::shared_ptr<const TunnelBase> & t2) const + template<typename T> + bool operator() (const std::shared_ptr<T> & t1, const std::shared_ptr<T> & t2) const { if (t1->GetCreationTime () != t2->GetCreationTime ()) return t1->GetCreationTime () > t2->GetCreationTime (); https://github.com/PurpleI2P/i2pd/commit/4af0caa50639c9c080034b2ea8239eb7e06f0ba3 Thank you, issue resolved. |