Skip to content

Commit

Permalink
Merge branch 'Gcc14Warnings' into 'master'
Browse files Browse the repository at this point in the history
Explicitly disable gcc's dangling ref. warning

See merge request ogs/ogs!5037
  • Loading branch information
endJunction committed Jul 6, 2024
2 parents d8b4cfc + 82a30a3 commit 91d3e1d
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 15 deletions.
1 change: 1 addition & 0 deletions Applications/CLI/ogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
*/

#include <algorithm>
#include <pybind11/pybind11.h>
#include <spdlog/spdlog.h>
#include <tclap/CmdLine.h>
Expand Down
1 change: 1 addition & 0 deletions Applications/CLI/ogs_embedded_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "ogs_embedded_python.h"

#include <algorithm>
#include <pybind11/embed.h>

#include "BaseLib/Logging.h"
Expand Down
1 change: 1 addition & 0 deletions Applications/CLI/ogs_embedded_python.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include <algorithm>
#include <pybind11/embed.h>

#include "BaseLib/ExportSymbol.h"
Expand Down
1 change: 1 addition & 0 deletions Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

#include <algorithm>
#include <pybind11/pybind11.h>

#include "ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h"
Expand Down
1 change: 1 addition & 0 deletions Applications/Python/ogs.mesh/OGSMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "OGSMesh.h"

#include <algorithm>
#include <pybind11/eigen.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
Expand Down
1 change: 1 addition & 0 deletions Applications/Python/ogs.mesh/OGSMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
*/

#include <algorithm>
#include <pybind11/pybind11.h>

#include <string>
Expand Down
1 change: 1 addition & 0 deletions Applications/Python/ogs.mesh/ogs_mesh_python_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*
*/

#include <algorithm>
#include <pybind11/eigen.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
Expand Down
1 change: 1 addition & 0 deletions Applications/Python/ogs.simulator/ogs_python_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*
*/

#include <algorithm>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <spdlog/spdlog.h>
Expand Down
11 changes: 6 additions & 5 deletions BaseLib/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <typeinfo>
#include <utility>

#include "CompilerWorkarounds.h"
#include "Error.h"

namespace BaseLib
Expand Down Expand Up @@ -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, typename Key>
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())
Expand All @@ -131,8 +132,8 @@ typename Map::mapped_type& getOrError(Map& map, Key const& key,
}
//! \overload
template <typename Map, typename Key>
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())
Expand All @@ -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, typename Predicate>
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)
Expand Down
16 changes: 16 additions & 0 deletions BaseLib/CompilerWorkarounds.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion BaseLib/FileTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions MeshGeoToolsLib/MeshNodeSearcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <memory>
#include <vector>

#include "BaseLib/CompilerWorkarounds.h"
#include "GeoLib/Grid.h"
#include "MathLib/Point3dWithID.h"
#include "MeshGeoToolsLib/SearchAllNodes.h"
Expand Down Expand Up @@ -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<MeshGeoToolsLib::SearchLength>&&
search_length_algorithm);
OGS_NO_DANGLING
static MeshNodeSearcher const&
getMeshNodeSearcher(MeshLib::Mesh const& mesh,
std::unique_ptr<MeshGeoToolsLib::SearchLength>&&
search_length_algorithm);

private:
MeshLib::Mesh const& _mesh;
Expand Down
14 changes: 9 additions & 5 deletions ParameterLib/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <vector>

#include "BaseLib/CompilerWorkarounds.h"
#include "BaseLib/ConfigTree.h"
#include "BaseLib/Error.h"
#include "Parameter.h"
Expand Down Expand Up @@ -98,10 +99,11 @@ Parameter<ParameterDataType>* findParameterOptional(
///
/// \see The documentation of the other findParameter() function.
template <typename ParameterDataType>
Parameter<ParameterDataType>& findParameter(
OGS_NO_DANGLING Parameter<ParameterDataType>& findParameter(
std::string const& parameter_name,
std::vector<std::unique_ptr<ParameterBase>> 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<ParameterDataType>(
parameter_name, parameters, num_components, mesh);
Expand Down Expand Up @@ -130,10 +132,12 @@ Parameter<ParameterDataType>& findParameter(
/// and return a reference to that parameter. Additionally it checks for the
/// type of the found parameter.
template <typename ParameterDataType>
Parameter<ParameterDataType>& findParameter(
BaseLib::ConfigTree const& process_config, std::string const& tag,
OGS_NO_DANGLING Parameter<ParameterDataType>& findParameter(
BaseLib::ConfigTree const& process_config,
std::string const& tag,
std::vector<std::unique_ptr<ParameterBase>> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#pragma once
#include <algorithm>
#include <pybind11/pybind11.h>

#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include <algorithm>
#include <pybind11/pybind11.h>

#include "BaseLib/ExportSymbol.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "CreatePythonSourceTerm.h"

#include <algorithm>
#include <pybind11/pybind11.h>

#include "BaseLib/ConfigTree.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "PythonBoundaryCondition.h"

#include <algorithm>
#include <pybind11/pybind11.h>

#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include <algorithm>
#include <pybind11/pybind11.h>

#include "BaseLib/ExportSymbol.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "PythonSourceTerm.h"

#include <algorithm>
#include <pybind11/pybind11.h>

#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "PythonSourceTermModule.h"

#include <algorithm>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include <algorithm>
#include <pybind11/pybind11.h>

#include "BaseLib/ExportSymbol.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "CreateHeatTransportBHEProcess.h"

#include <algorithm>
#include <pybind11/pybind11.h>

#include <vector>
Expand Down
8 changes: 8 additions & 0 deletions scripts/cmake/CompilerSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ if(COMPILER_IS_GCC OR COMPILER_IS_CLANG OR COMPILER_IS_INTEL)
$<$<COMPILE_LANGUAGE:CXX>:-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(
$<$<COMPILE_LANGUAGE:CXX>:-Wno-array-bounds>
$<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-overflow>
$<$<COMPILE_LANGUAGE:CXX>:-Wno-stringop-overread>
)
endif()
endif()

if(COMPILER_IS_CLANG)
Expand Down

0 comments on commit 91d3e1d

Please sign in to comment.