mirror of
https://github.com/ZmnSCPxj/clboss.git
synced 2026-08-16 13:00:59 +02:00
This commit addresses a compatibility issue introduced by GCC in version 13 (refer to [1]). The issue is present in both the Arch base system and the latest version of Fedora. To resolve this, the commit introduces a Kernel-mimicking approach through a new `Compiler.hpp` file. In this file, we define various compiler hacks required to enhance code readability by reducing verbosity. For more details on the issue, see [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107134 ``` In file included from ./Boss/Msg/RequestPeerFromScid.hpp:4, from Boss/Mod/PeerFromScidMapper.cpp:3: ./Ln/Scid.hpp:16:14: error: 'uint64_t' in namespace 'std' does not name a type; did you mean 'wint_t'? 16 | std::uint64_t val; | ^~~~~~~~ | wint_t ./Ln/Scid.hpp: In constructor 'Ln::Scid::Scid(std::nullptr_t)': ./Ln/Scid.hpp:19:44: error: class 'Ln::Scid' does not have any field named 'val' 19 | Scid(std::nullptr_t _ = nullptr) : val(0) { } | ^~~ ./Ln/Scid.hpp: In member function 'Ln::Scid::operator bool() const': ./Ln/Scid.hpp:25:24: error: 'val' was not declared in this scope 25 | return val != 0; | ^~~ ./Ln/Scid.hpp: In member function 'bool Ln::Scid::operator==(const Ln::Scid&) const': ./Ln/Scid.hpp:32:24: error: 'val' was not declared in this scope 32 | return val == i.val; | ^~~ ./Ln/Scid.hpp:32:33: error: 'const class Ln::Scid' has no member named 'val' 32 | return val == i.val; | ^~~ ./Ln/Scid.hpp: In member function 'bool Ln::Scid::operator<(const Ln::Scid&) const': ./Ln/Scid.hpp:39:24: error: 'val' was not declared in this scope 39 | return val < i.val; | ^~~ ./Ln/Scid.hpp:39:32: error: 'const class Ln::Scid' has no member named 'val' 39 | return val < i.val; | ^~~ /bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I./external/basicsecure/ -I./external/bitcoin-ripemd160/ -I./external/bitcoin-sha256/ -I./external/secp256k1/include/ -I./external/jsmn -Wall -Werror -pthread -Wno-noexcept-type -DUSE_VALGRIND -O2 -MT Boss/Mod/libclboss_la-UnmanagedManager.lo -MD -MP -MF Boss/Mod/.deps/libclboss_la-UnmanagedManager.Tpo -c -o Boss/Mod/libclboss_la-UnmanagedManager.lo `test -f 'Boss/Mod/UnmanagedManager.cpp' || echo './'`Boss/Mod/UnmanagedManager.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I./external/basicsecure/ -I./external/bitcoin-ripemd160/ -I./external/bitcoin-sha256/ -I./external/secp256k1/include/ -I./external/jsmn -Wall -Werror -pthread -Wno-noexcept-type -DUSE_VALGRIND -O2 -MT Boss/Mod/libclboss_la-UnmanagedManager.lo -MD -MP -MF Boss/Mod/.deps/libclboss_la-UnmanagedManager.Tpo -c Boss/Mod/UnmanagedManager.cpp -o Boss/Mod/libclboss_la-UnmanagedManager.o ``` Reported-by: Lakshya Singh <@king-11> Co-Developed-by: Lakshya Singh <@king-11> Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
94 lines
2.6 KiB
C++
94 lines
2.6 KiB
C++
#undef NDEBUG
|
|
#include"Util/Either.hpp"
|
|
#include<assert.h>
|
|
#include<cstdint>
|
|
#include<functional>
|
|
#include<set>
|
|
#include<string>
|
|
|
|
typedef Util::Either<std::uint64_t, std::string> Example;
|
|
|
|
int main() {
|
|
/* Safe construct / destruct tests.
|
|
* These are basically only usefully tested under
|
|
* valgrind.
|
|
*/
|
|
{
|
|
(void) Example();
|
|
(void) Example::left(0);
|
|
(void) Example::right("some long and pointless string");
|
|
(void) Example(Example::right("another string"));
|
|
auto foo = Example::right("yet another string");
|
|
(void) Example(foo);
|
|
}
|
|
|
|
/* Equality checks. */
|
|
{
|
|
assert(Example::left(0) == Example::left(0));
|
|
assert(Example::left(0) != Example::left(42));
|
|
assert(Example::right("hot diggity string") == Example::right("hot diggity string"));
|
|
assert(Example::right("hot diggity string") != Example::right("not a hot diggity string"));
|
|
assert(Example::left(0) != Example::right("some arbitrary string"));
|
|
|
|
auto a = Example::left(100);
|
|
auto b = a;
|
|
assert(a == b);
|
|
auto c = Example::right("stringity string");
|
|
auto d = c;
|
|
assert(c == d);
|
|
assert(a != c);
|
|
}
|
|
|
|
/* Ordering checks. */
|
|
{
|
|
assert(!(Example::left(0) < Example::left(0)));
|
|
assert(!(Example::left(0) > Example::left(0)));
|
|
assert(Example::left(0) <= Example::left(0));
|
|
assert(Example::left(0) >= Example::left(0));
|
|
|
|
auto a = Example::left(0);
|
|
auto b = Example::left(1);
|
|
auto c = Example::right("asdf fdsa asdf");
|
|
assert(((Example const&)a) < ((Example const&)b));
|
|
assert(std::less<Example>{}(a, b));
|
|
assert(std::less<Example>{}(b, c));
|
|
assert(c > b);
|
|
assert(a <= a);
|
|
assert(a <= b);
|
|
assert(c >= b);
|
|
assert(c >= c);
|
|
|
|
auto s = std::set<Example>();
|
|
s.insert(Example::left(0));
|
|
s.insert(Example::left(1));
|
|
s.insert(Example::right("a very long string"));
|
|
s.insert(Example::right("a not very long string"));
|
|
assert(s.find(Example::left(0)) != s.end());
|
|
assert(s.find(Example::left(1)) != s.end());
|
|
assert(s.find(Example::left(2)) == s.end());
|
|
assert(s.find(Example::right("nothing at all like this")) == s.end());
|
|
assert(s.find(Example::right("a very long string")) != s.end());
|
|
}
|
|
|
|
/* Swap and safe assignment checks.
|
|
* Note: Safety requires valgrind to check.
|
|
*/
|
|
{
|
|
auto a = Example::left(0);
|
|
auto b = Example::right("yet another string in my test");
|
|
assert(a < b);
|
|
a.swap(b);
|
|
assert(b < a);
|
|
a = b;
|
|
a = a;
|
|
assert(a == b);
|
|
|
|
a = Example::left(0);
|
|
b = Example::right("another string another check");
|
|
assert(a != b);
|
|
assert(a == Example::left(0));
|
|
assert(b == Example::right("another string another check"));
|
|
a = std::move(b);
|
|
assert(a == Example::right("another string another check"));
|
|
}
|
|
}
|