diff --git a/cmake/CompilerFlags.cmake b/cmake/CompilerFlags.cmake index cb7e26e0db3..9b1d5c9ef05 100644 --- a/cmake/CompilerFlags.cmake +++ b/cmake/CompilerFlags.cmake @@ -120,6 +120,10 @@ elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" O # depending on the level of overflow check selected, the stringop-overflow can also emit false positives # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstringop-overflow target_compile_options(project_warnings INTERFACE -Wno-stringop-overflow) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0) + # GCC 15 emits false positives through libstdc++ when compiling bundled fmt 8.0.1 with -Werror + target_compile_options(project_warnings INTERFACE -Wno-restrict) + endif() # for RelWithDebInfo builds, lets turn OFF NDEBUG, which will re-enable assert statements target_compile_options(project_options INTERFACE $<$:-UNDEBUG>) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index ce2fcaa3531..fad3b470fd9 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -800,6 +800,9 @@ target_link_libraries( target_link_libraries(energypluslib PRIVATE project_options project_fp_options project_warnings) ep_enable_pch(energypluslib) +if(LINK_WITH_PYTHON) + set_source_files_properties(PluginManager.cc PythonEngine.cc PROPERTIES SKIP_PRECOMPILE_HEADERS ON) +endif() if(OPENGL_FOUND) target_link_libraries(energypluslib PUBLIC penumbra) diff --git a/src/EnergyPlus/PluginManager.cc b/src/EnergyPlus/PluginManager.cc index 9681ffdfdce..30f15bced78 100644 --- a/src/EnergyPlus/PluginManager.cc +++ b/src/EnergyPlus/PluginManager.cc @@ -45,20 +45,7 @@ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - #if LINK_WITH_PYTHON - # ifdef _DEBUG // We don't want to try to import a debug build of Python here // so if we are building a Debug build of the C++ code, we need @@ -70,7 +57,21 @@ # else # include # endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#if LINK_WITH_PYTHON # include template <> struct fmt::formatter { diff --git a/src/EnergyPlus/PythonEngine.cc b/src/EnergyPlus/PythonEngine.cc index 9d2f50d4423..8f14d3db70b 100644 --- a/src/EnergyPlus/PythonEngine.cc +++ b/src/EnergyPlus/PythonEngine.cc @@ -45,11 +45,6 @@ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -#include -#include -#include -#include - #if LINK_WITH_PYTHON # ifdef _DEBUG // We don't want to try to import a debug build of Python here @@ -62,7 +57,14 @@ # else # include # endif +#endif +#include +#include +#include +#include + +#if LINK_WITH_PYTHON # include namespace fmt { template <> struct formatter diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 8b11c5ecf59..4157c3c40ca 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -86,6 +86,9 @@ set(CMAKE_CXX_STANDARD 20) if(NOT MSVC) add_compile_options(-Wno-pedantic -Wno-unused-parameter -Wno-unknown-pragmas) + if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0) + add_compile_options($<$:-Wno-dangling-reference> $<$:-Wno-restrict>) + endif() else() add_compile_options(/wd4267 /wd4996 /wd4068 /wd4244 /wd4589) endif() diff --git a/third_party/ObjexxFCL/src/ObjexxFCL/AlignedAllocator.hh b/third_party/ObjexxFCL/src/ObjexxFCL/AlignedAllocator.hh index d15400f1375..b994b6fbe9d 100644 --- a/third_party/ObjexxFCL/src/ObjexxFCL/AlignedAllocator.hh +++ b/third_party/ObjexxFCL/src/ObjexxFCL/AlignedAllocator.hh @@ -20,6 +20,8 @@ #include #include #include +#include +#include namespace ObjexxFCL { @@ -38,16 +40,29 @@ public: // Types public: // Static Methods - // Allocate Raw Array Memory with ::operator new + // Raw allocation size including optional alignment padding static - void * - allocate( size_type const n ) + size_type + allocation_size( size_type const n ) { #ifdef OBJEXXFCL_ALIGN - void * mem( n > 0u ? ::operator new( ( n * sizeof( T ) ) + ( OBJEXXFCL_ALIGN - 1 ) ) : nullptr ); + constexpr size_type alignment_overhead( OBJEXXFCL_ALIGN > 0u ? OBJEXXFCL_ALIGN - 1u : 0u ); #else - void * mem( n > 0u ? ::operator new( n * sizeof( T ) ) : nullptr ); + constexpr size_type alignment_overhead( 0u ); #endif + constexpr size_type max_size( static_cast< size_type >( std::numeric_limits< std::ptrdiff_t >::max() ) ); + if ( n > ( max_size - alignment_overhead ) / sizeof( T ) ) { + throw std::bad_array_new_length(); + } + return ( n * sizeof( T ) ) + alignment_overhead; + } + + // Allocate Raw Array Memory with ::operator new + static + void * + allocate( size_type const n ) + { + void * mem( n > 0u ? ::operator new( allocation_size( n ) ) : nullptr ); assert( ( n == 0u ) || ( mem != nullptr ) ); return mem; } @@ -57,11 +72,7 @@ public: // Static Methods void * allocate_zero( size_type const n ) { -#ifdef OBJEXXFCL_ALIGN - void * mem( ::operator new( ( n * sizeof( T ) ) + ( OBJEXXFCL_ALIGN - 1 ) ) ); -#else - void * mem( ::operator new( n * sizeof( T ) ) ); -#endif + void * mem( ::operator new( allocation_size( n ) ) ); assert( ( n == 0u ) || ( mem != nullptr ) ); return mem; } diff --git a/third_party/ssc/shared/lib_battery_dispatch.cpp b/third_party/ssc/shared/lib_battery_dispatch.cpp index 6b3acbf7d9a..3a0b5a50c06 100644 --- a/third_party/ssc/shared/lib_battery_dispatch.cpp +++ b/third_party/ssc/shared/lib_battery_dispatch.cpp @@ -26,6 +26,7 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include /* Dispatch base class diff --git a/tst/EnergyPlus/unit/FluidProperties.unit.cc b/tst/EnergyPlus/unit/FluidProperties.unit.cc index 2a8c0adbc04..be45622aa1b 100644 --- a/tst/EnergyPlus/unit/FluidProperties.unit.cc +++ b/tst/EnergyPlus/unit/FluidProperties.unit.cc @@ -54,7 +54,7 @@ #include #include -#include +#include #include "Fixtures/EnergyPlusFixture.hh"