From cfb5f829486857aadbf6b177b1a65b7a30e9cd65 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sun, 7 Jul 2024 03:58:42 +0000 Subject: [PATCH] Add __builtin_constant_p for gcc build without optimizations --- cmake/check.cpp | 8 +++----- cmake/cserverConfig.cmake.in | 2 +- include/cserver/engine/components.hpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmake/check.cpp b/cmake/check.cpp index fb66b2c..bb9ddad 100644 --- a/cmake/check.cpp +++ b/cmake/check.cpp @@ -3,8 +3,8 @@ #include struct SomeStruct { - constexpr SomeStruct(auto&& arg) { - arg.Method(42); + explicit constexpr SomeStruct(auto&& arg) { + arg.Method(42); // NOLINT }; }; @@ -15,15 +15,13 @@ struct Injector { template inline constexpr auto Use() { - std::ignore = T{Args...}; + std::ignore = __builtin_constant_p(T{Args...}); }; template consteval auto Ignore() {}; - auto main() -> int { Ignore())>(); static_assert(std::is_same_v{})), utempl::TypeList>); }; - diff --git a/cmake/cserverConfig.cmake.in b/cmake/cserverConfig.cmake.in index c7e7b35..6e43fcf 100644 --- a/cmake/cserverConfig.cmake.in +++ b/cmake/cserverConfig.cmake.in @@ -6,5 +6,5 @@ check_required_components("@PROJECT_NAME@") try_compile(loopholes_body_inject SOURCES "${CMAKE_CURRENT_LIST_DIR}/check.cpp") if(NOT loopholes_body_inject) - message(FATAL_ERROR "The Compiler Doesn't Support Retrieval Of Information Via Loopholes. If You Are Using gcc, Enable Optimizations.") + message(FATAL_ERROR "The Compiler Doesn't Support Retrieval Of Information Via Loopholes.") endif() diff --git a/include/cserver/engine/components.hpp b/include/cserver/engine/components.hpp index 0ae291e..3592ac7 100644 --- a/include/cserver/engine/components.hpp +++ b/include/cserver/engine/components.hpp @@ -336,7 +336,7 @@ struct DependencyInfoKey {}; template inline constexpr auto Use() { - std::ignore = T{Args...}; + std::ignore = __builtin_constant_p(T{Args...}); }; template