Skip to content

Commit

Permalink
Silence compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento authored Mar 27, 2024
2 parents 65b3b70 + 601bbab commit f78b1cb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
23 changes: 23 additions & 0 deletions 3rdparty/cereal/include/cereal/details/polymorphic_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@ namespace cereal
template <class Derived> inline
static const Derived * downcast( const void * dptr, std::type_info const & baseInfo )
{
#pragma GCC diagnostic push
#if defined(__GNUC__) && (__GNUC__ >= 13)
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
// Without the warning suppression, the following source line generates a warning in GNU GCC 13.x
// The warning is a false positive, reported as a GCC compiler regression: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
auto const & mapping = lookup( baseInfo, typeid(Derived), [&](){ UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION(save) } );
#pragma GCC diagnostic pop

for( auto const * dmap : mapping )
dptr = dmap->downcast( dptr );
Expand All @@ -200,7 +207,15 @@ namespace cereal
template <class Derived> inline
static void * upcast( Derived * const dptr, std::type_info const & baseInfo )
{
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#if defined(__GNUC__) && (__GNUC__ >= 13)
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
// Without the warning suppression, the following source line generates a warning in GNU GCC 13.x
// The warning is a false positive, reported as a GCC compiler regression: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
auto const & mapping = lookup( baseInfo, typeid(Derived), [&](){ UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION(load) } );
#pragma GCC diagnostic pop

void * uptr = dptr;
for( auto mIter = mapping.rbegin(), mEnd = mapping.rend(); mIter != mEnd; ++mIter )
Expand All @@ -213,7 +228,15 @@ namespace cereal
template <class Derived> inline
static std::shared_ptr<void> upcast( std::shared_ptr<Derived> const & dptr, std::type_info const & baseInfo )
{
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#if defined(__GNUC__) && (__GNUC__ >= 13)
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
// Without the warning suppression, the following source line generates a warning in GNU GCC 13.x
// The warning is a false positive, reported as a GCC compiler regression: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532
auto const & mapping = lookup( baseInfo, typeid(Derived), [&](){ UNREGISTERED_POLYMORPHIC_CAST_EXCEPTION(load) } );
#pragma GCC diagnostic pop

std::shared_ptr<void> uptr = dptr;
for( auto mIter = mapping.rbegin(), mEnd = mapping.rend(); mIter != mEnd; ++mIter )
Expand Down
8 changes: 7 additions & 1 deletion cmake/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ if (HAVE_WARNINGS)
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wno-deprecated-declarations>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wno-unused-result>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wno-unused-parameter>
## Clang (MacOS AppleClang + Homebrew, AMD Clang-base)
## Clang (MacOS Homebrew, AMD Clang-base)
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:-Wno-deprecated-copy-with-user-provided-copy> # silence warnings in Qt5 related headers
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:-Wno-deprecated-declarations>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:-Wno-missing-field-initializers> # silence warning in Boost.Python related headers
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:-Wno-overloaded-virtual>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Clang>>:-Wno-unused-parameter>
## Clang (MacOS AppleClang)
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-deprecated-copy-with-user-provided-copy> # silence warnings in Qt5 related headers
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-deprecated-declarations>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-missing-field-initializers> # silence warning in Boost.Python related headers
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-overloaded-virtual>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-unused-parameter>
## Clang (Intel Clang-based)
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:IntelLLVM>>:-Wno-deprecated-copy-with-user-provided-copy> # silence warnings in Qt5 related headers
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:IntelLLVM>>:-Wno-deprecated-declarations>
Expand Down
10 changes: 5 additions & 5 deletions libs/core/src/ecflow/core/Chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ DurationOut parse_duration(const std::string& d) {
// Extract tail
std::string tail = d.substr(found + 1, std::string::npos);

// Important!
// The whole duration has the same sign as the first component
// e.g. -23:59:59, is interpreted as (-23 hours) + (-59 minutes) + (-59 seconds) = -86399 seconds
int sign = value >= FirstDuration{0} ? 1 : -1;

if constexpr (sizeof...(RestDurations) > 0) {
// Important!
// The whole duration has the same sign as the first component
// e.g. -23:59:59, is interpreted as (-23 hours) + (-59 minutes) + (-59 seconds) = -86399 seconds
int sign = value >= FirstDuration{0} ? 1 : -1;

out = out + (sign)*parse_duration<DurationOut, RestDurations...>(tail);
}

Expand Down
1 change: 1 addition & 0 deletions libs/rest/src/ecflow/http/ApiV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ ojson filter_json(const ojson& j, const httplib::Request& r) {
// correct array element from root json element assuming it's an array
if (path_elems.size() == 1 && path_elems[0][0] == '[' && path_elems[0][path_elems[0].size() - 1] == ']') {
const auto [key, index] = get_array_info(path_elems[0]);
(void)key; // Note: suppress unused variable warning
return j[index];
}

Expand Down
7 changes: 4 additions & 3 deletions libs/rest/src/ecflow/http/Base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ inline unsigned char* base64_decode(const unsigned char* src, size_t len, size_t

memset(dtable, 0x80, 256);
for (size_t i = 0; i < sizeof(base64_table) - 1; i++) {
dtable[base64_table[i]] = (unsigned char)i;
auto base64_char = static_cast<size_t>(base64_table[i]);
dtable[base64_char] = (unsigned char)i;
}
int assignment = '=';
dtable[assignment] = 0;
size_t assignment_char = '=';
dtable[assignment_char] = 0;

size_t count = 0;
for (size_t i = 0; i < len; i++) {
Expand Down
4 changes: 2 additions & 2 deletions libs/rest/src/ecflow/http/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ const char* const ECF_PASS = getenv("ECF_PASS");

bool authenticate(const httplib::Request& request, ClientInvoker* ci) {

auto auth_with_token = [&](const std::string& token) {
#ifdef ECF_OPENSSL
auto auth_with_token = [&](const std::string& token) {
if (TokenStorage::instance().verify(token)) {
if (ECF_USER != nullptr && ECF_PASS != nullptr) {
ci->set_user_name(std::string(ECF_USER));
ci->set_password(std::string(ECF_PASS));
}
return true;
}
#endif
return false;
};
#endif

const auto& header = request.headers;

Expand Down

0 comments on commit f78b1cb

Please sign in to comment.