diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index caa37888ab3..9c44b21ec0e 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -11,6 +11,7 @@ * */ +#include #include #include #include diff --git a/Applications/CLI/ogs_embedded_python.cpp b/Applications/CLI/ogs_embedded_python.cpp index 4edcc3d9eaa..1a16f5afb3d 100644 --- a/Applications/CLI/ogs_embedded_python.cpp +++ b/Applications/CLI/ogs_embedded_python.cpp @@ -10,6 +10,7 @@ #include "ogs_embedded_python.h" +#include #include #include "BaseLib/Logging.h" diff --git a/Applications/CLI/ogs_embedded_python.h b/Applications/CLI/ogs_embedded_python.h index 2d713303f6e..a723d7eb7cf 100644 --- a/Applications/CLI/ogs_embedded_python.h +++ b/Applications/CLI/ogs_embedded_python.h @@ -10,6 +10,7 @@ #pragma once +#include #include #include "BaseLib/ExportSymbol.h" diff --git a/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp b/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp index c588f69ff15..c2e0789138c 100644 --- a/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp +++ b/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp @@ -8,6 +8,7 @@ * */ +#include #include #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h" diff --git a/Applications/Python/ogs.mesh/OGSMesh.cpp b/Applications/Python/ogs.mesh/OGSMesh.cpp index 307a710afb7..bcd237cc56d 100644 --- a/Applications/Python/ogs.mesh/OGSMesh.cpp +++ b/Applications/Python/ogs.mesh/OGSMesh.cpp @@ -12,6 +12,7 @@ #include "OGSMesh.h" +#include #include #include #include diff --git a/Applications/Python/ogs.mesh/OGSMesh.h b/Applications/Python/ogs.mesh/OGSMesh.h index c36d3e5f5fd..62e720be34c 100644 --- a/Applications/Python/ogs.mesh/OGSMesh.h +++ b/Applications/Python/ogs.mesh/OGSMesh.h @@ -9,6 +9,7 @@ * */ +#include #include #include diff --git a/Applications/Python/ogs.mesh/ogs_mesh_python_module.cpp b/Applications/Python/ogs.mesh/ogs_mesh_python_module.cpp index c84712fbb0c..003e287fb80 100644 --- a/Applications/Python/ogs.mesh/ogs_mesh_python_module.cpp +++ b/Applications/Python/ogs.mesh/ogs_mesh_python_module.cpp @@ -10,6 +10,7 @@ * */ +#include #include #include #include diff --git a/Applications/Python/ogs.simulator/ogs_python_module.cpp b/Applications/Python/ogs.simulator/ogs_python_module.cpp index 35d48baa74c..ea445757003 100644 --- a/Applications/Python/ogs.simulator/ogs_python_module.cpp +++ b/Applications/Python/ogs.simulator/ogs_python_module.cpp @@ -10,6 +10,7 @@ * */ +#include #include #include #include diff --git a/BaseLib/Algorithm.h b/BaseLib/Algorithm.h index f613f1d7c11..371f14622cd 100644 --- a/BaseLib/Algorithm.h +++ b/BaseLib/Algorithm.h @@ -21,6 +21,7 @@ #include #include +#include "CompilerWorkarounds.h" #include "Error.h" namespace BaseLib @@ -110,8 +111,8 @@ void insertIfKeyUniqueElseError(Map& map, Key const& key, Value&& value, //! otherwise an \c error_message is printed and the program is aborted. //! Cf. also the const overload below. template -typename Map::mapped_type& getOrError(Map& map, Key const& key, - std::string const& error_message) +OGS_NO_DANGLING typename Map::mapped_type& getOrError( + Map& map, Key const& key, std::string const& error_message) { auto it = map.find(key); if (it == map.end()) @@ -131,8 +132,8 @@ typename Map::mapped_type& getOrError(Map& map, Key const& key, } //! \overload template -typename Map::mapped_type const& getOrError(Map const& map, Key const& key, - std::string const& error_message) +OGS_NO_DANGLING typename Map::mapped_type const& getOrError( + Map const& map, Key const& key, std::string const& error_message) { auto it = map.find(key); if (it == map.end()) @@ -155,7 +156,7 @@ typename Map::mapped_type const& getOrError(Map const& map, Key const& key, //! the \c predicate exists; //! otherwise an \c error_message is printed and the program is aborted. template -typename Container::value_type const& getIfOrError( +OGS_NO_DANGLING typename Container::value_type const& getIfOrError( Container const& container, Predicate&& predicate, std::string const& error_message) diff --git a/BaseLib/CompilerWorkarounds.h b/BaseLib/CompilerWorkarounds.h new file mode 100644 index 00000000000..479d270a82e --- /dev/null +++ b/BaseLib/CompilerWorkarounds.h @@ -0,0 +1,16 @@ +/** + * \file + * \copyright + * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#pragma once + +#if defined(__GNUC__) && __GNUC__ == 14 +#define OGS_NO_DANGLING [[gnu::no_dangling]] +#else +#define OGS_NO_DANGLING +#endif diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index 2085e41e09a..4b7a506e9cc 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -103,7 +103,7 @@ bool substituteKeyword(std::string& result, type_specification[std::type_index(typeid(std::string))] = 's'; auto const& b = precision_specification.back(); - // see https://fmt.dev/latest/syntax.html#formatspec + // see https://fmt.dev/latest/syntax/#format-specification-mini-language if (b == 'e' || b == 'E' || b == 'f' || b == 'F' || b == 'g' || b == 'G') { type_specification[std::type_index(typeid(double))] = b; diff --git a/MeshGeoToolsLib/MeshNodeSearcher.h b/MeshGeoToolsLib/MeshNodeSearcher.h index 9aa05163b80..834a37a6229 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.h +++ b/MeshGeoToolsLib/MeshNodeSearcher.h @@ -13,6 +13,7 @@ #include #include +#include "BaseLib/CompilerWorkarounds.h" #include "GeoLib/Grid.h" #include "MathLib/Point3dWithID.h" #include "MeshGeoToolsLib/SearchAllNodes.h" @@ -87,10 +88,11 @@ class MeshNodeSearcher * Returns a (possibly new) mesh node searcher for the mesh. * A new one will be created, if it does not already exists. */ - static MeshNodeSearcher const& getMeshNodeSearcher( - MeshLib::Mesh const& mesh, - std::unique_ptr&& - search_length_algorithm); + OGS_NO_DANGLING + static MeshNodeSearcher const& + getMeshNodeSearcher(MeshLib::Mesh const& mesh, + std::unique_ptr&& + search_length_algorithm); private: MeshLib::Mesh const& _mesh; diff --git a/ParameterLib/Utils.h b/ParameterLib/Utils.h index d459cc021aa..ef1580fbfaf 100644 --- a/ParameterLib/Utils.h +++ b/ParameterLib/Utils.h @@ -12,6 +12,7 @@ #include +#include "BaseLib/CompilerWorkarounds.h" #include "BaseLib/ConfigTree.h" #include "BaseLib/Error.h" #include "Parameter.h" @@ -98,10 +99,11 @@ Parameter* findParameterOptional( /// /// \see The documentation of the other findParameter() function. template -Parameter& findParameter( +OGS_NO_DANGLING Parameter& findParameter( std::string const& parameter_name, std::vector> const& parameters, - int const num_components, MeshLib::Mesh const* const mesh = nullptr) + int const num_components, + MeshLib::Mesh const* const mesh = nullptr) { auto* parameter = findParameterOptional( parameter_name, parameters, num_components, mesh); @@ -130,10 +132,12 @@ Parameter& findParameter( /// and return a reference to that parameter. Additionally it checks for the /// type of the found parameter. template -Parameter& findParameter( - BaseLib::ConfigTree const& process_config, std::string const& tag, +OGS_NO_DANGLING Parameter& findParameter( + BaseLib::ConfigTree const& process_config, + std::string const& tag, std::vector> const& parameters, - int const num_components, MeshLib::Mesh const* const mesh = nullptr) + int const num_components, + MeshLib::Mesh const* const mesh = nullptr) { // Find parameter name in process config. //! \ogs_file_special diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryCondition.h b/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryCondition.h index 081f8b19513..25746dc1d8a 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryCondition.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryCondition.h @@ -9,6 +9,7 @@ */ #pragma once +#include #include #include diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h b/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h index 74c05438340..97a7fedfe2e 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h @@ -10,6 +10,7 @@ #pragma once +#include #include #include "BaseLib/ExportSymbol.h" diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/CreatePythonSourceTerm.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/Python/CreatePythonSourceTerm.cpp index 0f89bf450f3..d16b497b222 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/CreatePythonSourceTerm.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/CreatePythonSourceTerm.cpp @@ -10,6 +10,7 @@ #include "CreatePythonSourceTerm.h" +#include #include #include "BaseLib/ConfigTree.h" diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryCondition.cpp index 1f981fa125c..0bb86a848ef 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryCondition.cpp @@ -10,6 +10,7 @@ #include "PythonBoundaryCondition.h" +#include #include #include diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h index 242b9a0c2ba..24ffa43d04b 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h @@ -10,6 +10,7 @@ #pragma once +#include #include #include "BaseLib/ExportSymbol.h" diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTerm.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTerm.cpp index 003c3537533..7ed300342be 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTerm.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTerm.cpp @@ -10,6 +10,7 @@ #include "PythonSourceTerm.h" +#include #include #include diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.cpp index 7c7d0583091..791a1e980d3 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.cpp @@ -10,6 +10,7 @@ #include "PythonSourceTermModule.h" +#include #include #include diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h index 994b9de7e15..1fc32e0f9cd 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h @@ -10,6 +10,7 @@ #pragma once +#include #include #include "BaseLib/ExportSymbol.h" diff --git a/ProcessLib/HeatTransportBHE/CreateHeatTransportBHEProcess.cpp b/ProcessLib/HeatTransportBHE/CreateHeatTransportBHEProcess.cpp index 95eaca0a01b..2e215b8c31e 100644 --- a/ProcessLib/HeatTransportBHE/CreateHeatTransportBHEProcess.cpp +++ b/ProcessLib/HeatTransportBHE/CreateHeatTransportBHEProcess.cpp @@ -10,6 +10,7 @@ #include "CreateHeatTransportBHEProcess.h" +#include #include #include diff --git a/scripts/cmake/CompilerSetup.cmake b/scripts/cmake/CompilerSetup.cmake index 2fa6a6fe990..27762066a96 100644 --- a/scripts/cmake/CompilerSetup.cmake +++ b/scripts/cmake/CompilerSetup.cmake @@ -77,6 +77,14 @@ if(COMPILER_IS_GCC OR COMPILER_IS_CLANG OR COMPILER_IS_INTEL) $<$:-Wno-stringop-overread> ) endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14.1.1) + # See https://gitlab.opengeosys.org/ogs/ogs/-/merge_requests/5037 + add_compile_options( + $<$:-Wno-array-bounds> + $<$:-Wno-stringop-overflow> + $<$:-Wno-stringop-overread> + ) + endif() endif() if(COMPILER_IS_CLANG)