Skip to content

Commit

Permalink
Workaround for gcc13 false positive warning
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauger committed Sep 7, 2024
1 parent add02f4 commit f5c759e
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 16 deletions.
2 changes: 2 additions & 0 deletions cmake/BayeuxDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ endif()
if (Boost_VERSION VERSION_GREATER_EQUAL 107400)
message(STATUS "Forcing BOOST_BIND_GLOBAL_PLACEHOLDERS...")
add_definitions("-DBOOST_BIND_GLOBAL_PLACEHOLDERS")
# 2024-09-06 FM: disable for boost/spirit/include/phoenix_core.hpp and others...
add_definitions("-DBOOST_ALLOW_DEPRECATED_HEADERS")
endif()

foreach(_boost_lib ${BAYEUX_BOOST_COMPONENTS})
Expand Down
26 changes: 19 additions & 7 deletions source/bxdatatools/testing/test_enriched_base.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <datatools/enriched_base.h>

#if DATATOOLS_WITH_REFLECTION == 1
#include <datatools/detail/api.h> // for __GNUC_VERSION__
// - Camp:
#include <camp/userobject.hpp>
#include <camp/value.hpp>
Expand All @@ -30,13 +31,6 @@ void test2();
void test_reflection();
#endif // DATATOOLS_WITH_REFLECTION == 1

#if defined(__GNUG__)
#pragma GCC diagnostic ignored "-Werror=dangling-reference"
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Werror=dangling-reference"
#endif

int main(int /* argc_ */, char ** /* argv_ */)
{
int error_code = EXIT_SUCCESS;
Expand Down Expand Up @@ -100,10 +94,28 @@ void test2()
}

#if DATATOOLS_WITH_REFLECTION == 1
#if defined(__GNUG__)
#if GCC_VERSION >= 13
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#endif
void test_reflection()
{
std::cerr << "\n******** Entering test_reflection... " << std::endl;
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif
const camp::Class & aoMetaClass = camp::classByName("datatools::enriched_base");
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic pop
// #endif
// #endif
std::cerr << "******** Go. " << std::endl;

camp::UserObject aoObj = aoMetaClass.construct();
Expand Down
8 changes: 6 additions & 2 deletions source/bxdatatools/testing/test_handle_operators.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ bool test_handle_deref_operator()
x.reset();
bool gotException{false};
try {
auto sz = x->size();
std::clog << "sz=" << sz << '\n';
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-value"
x->size();
#pragma GCC diagnostic pop
#endif
} catch (std::logic_error& e) {
//o.k., we've caught the expected error
gotException = true;
Expand Down
74 changes: 70 additions & 4 deletions source/bxdatatools/testing/test_reflection_0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
#include <datatools/properties.h>
#include <datatools/multi_properties.h>
#include <datatools/things.h>
#include <datatools/detail/api.h> // for __GNUC_VERSION__

#if defined(__GNUG__)
#pragma GCC diagnostic ignored "-Werror=dangling-reference"
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
#pragma message "GCC13 workaround : applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Werror=dangling-reference"
#endif

void test_things(bool /*debug_*/);
Expand Down Expand Up @@ -92,7 +93,20 @@ void test_things (bool /*debug_*/)
std::clog << "*** test_things : " << std::endl;

// Access meta class for class 'things' :
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif
const camp::Class & tMetaClass = camp::classByName("datatools::things");
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Restoring original diagnostic conditions"
// #pragma GCC diagnostic pop
// #endif
// #endif
{

// Allocate a new 'things' object from the metaclass factory
Expand Down Expand Up @@ -155,7 +169,20 @@ void test_things (bool /*debug_*/)
void test_multi_properties (bool /*debug_*/)
{
std::clog << "*** test_multi_properties : " << std::endl;
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif
const camp::Class & mpropsMetaClass = camp::classByName("datatools::multi_properties");
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic pop
// #endif
// #endif
{
camp::UserObject mpropsObj = mpropsMetaClass.construct(camp::Args ("id", "class"));

Expand Down Expand Up @@ -212,7 +239,20 @@ void test_multi_properties (bool /*debug_*/)
void test_properties (bool /*debug_*/)
{
std::clog << "*** test_properties : " << std::endl;
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif
const camp::Class & propsMetaClass = camp::classByName("datatools::properties");
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic pop
// #endif
// #endif

{
//boost::scoped_ptr<datatools::properties> props (propsMetaClass.construct<datatools::properties> (camp::Args ("A test properties")));
Expand Down Expand Up @@ -256,7 +296,20 @@ void test_properties (bool /*debug_*/)
void test_event_id (bool /*debug_*/)
{
std::clog << "*** test_event_id : " << std::endl;
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif
const camp::Class & evIdMetaClass = camp::classByName("datatools::event_id");
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic pop
// #endif
// #endif

{
//boost::scoped_ptr<datatools::event_id> evId (evIdMetaClass.construct<datatools::event_id> (camp::Args (3, 55)));
Expand Down Expand Up @@ -290,7 +343,20 @@ void test_logger (bool /*debug_*/)
{
std::clog << "*** test_logger : " << std::endl;
{
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif
const camp::Class & tMetaClass = camp::classByName("datatools::logger");
// #if defined(__GNUC__)
// #if __GNUC_VERSION__ >= 130000
// // #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
// #pragma GCC diagnostic pop
// #endif
// #endif
std::clog << "tMetaClass = " << tMetaClass.name() << std::endl;

try {
Expand Down
6 changes: 3 additions & 3 deletions source/bxgenbb_help/programs/genbb_inspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@
#include <genbb_help/primary_event.ipp>
#include <genbb_help/version.h>
#include <genbb_help/resource.h>
#include <datatools/detail/api.h> // for __GNUC_VERSION__

#if defined(__GNUG__)
#pragma GCC diagnostic ignored "-Werror=dangling-reference"
#if GCC_VERSION >= 13
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Werror=dangling-reference"
#endif

namespace dtc = datatools::configuration;
Expand Down
33 changes: 33 additions & 0 deletions source/bxgenbb_help/testing/test_reflection_0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
// - Bayeux/datatools:
#include <datatools/logger.h>
#include <datatools/clhep_units.h>
#include <datatools/detail/api.h> // for __GNUC_VERSION__

// Introspectable classes :
#include <genbb_help/primary_particle.h>
#include <genbb_help/primary_event.h>

// #if defined(__GNUG__)
// #if GCC_VERSION >= 13
// #pragma GCC diagnostic ignored "-Wdangling-reference"
// #endif
// #endif

void test_primary_particle();
void test_primary_event();

Expand Down Expand Up @@ -61,7 +68,20 @@ int main (int /* argc_ */, char ** /* argv_ */)
void test_primary_particle()
{
datatools::logger::priority logging = datatools::logger::PRIO_NOTICE;
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
// #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#endif
const camp::Class & ppMetaClass = camp::classByName("genbb::primary_particle");
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
// #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic pop
#endif
#endif

camp::UserObject partObj0 = ppMetaClass.construct();
DT_LOG_NOTICE(logging, "Initializing the primary particle object...");
Expand All @@ -87,7 +107,20 @@ void test_primary_particle()
void test_primary_event()
{
//datatools::logger::priority logging = datatools::logger::PRIO_NOTICE;
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
// #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#endif
const camp::Class & peMetaClass = camp::classByName("genbb::primary_event");
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
// #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic pop
#endif
#endif

camp::UserObject eventObj0 = peMetaClass.construct();

Expand Down
20 changes: 20 additions & 0 deletions source/bxgeomtools/testing/test_reflection_0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,38 @@
// - Bayeux/datatools:
#include <datatools/logger.h>
#include <datatools/clhep_units.h>
#include <datatools/detail/api.h> // for __GNUC_VERSION__

// Introspectable classes :
#include <geomtools/utils.h>
#include <geomtools/geom_id.h>
#include <geomtools/base_hit.h>
#include <geomtools/placement.h>

#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
#pragma message "GCC13 workaround : applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#endif

void test_placement()
{
datatools::logger::priority logging = datatools::logger::PRIO_NOTICE;
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
// #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
#endif
const camp::Class & plctMetaClass = camp::classByName("geomtools::placement");
#if defined(__GNUC__)
#if __GNUC_VERSION__ >= 130000
// #pragma message "Applying special diagnostic ignored '-Wdangling-reference'"
#pragma GCC diagnostic pop
#endif
#endif

camp::UserObject plctObj0 = plctMetaClass.construct();

Expand Down

0 comments on commit f5c759e

Please sign in to comment.