summarylogtreecommitdiffstats
path: root/0005-cmake-gcc-disable-Werror-maybe-uninitialized-for-GCC.patch
blob: e48bb01480bf87aea3b7f0eead034aed18b7d92b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From 21a4a675dd74167552e6c78de432cd627e395481 Mon Sep 17 00:00:00 2001
From: Robert Falkenberg <robert.falkenberg@srs.io>
Date: Tue, 17 May 2022 15:10:41 +0200
Subject: [PATCH] cmake/gcc: disable [-Werror=maybe-uninitialized] for GCC >=
 12.1.0

With GCC 12.1.0 there are numerous false-positive warnings on
"maybe uninitialized" variables.
---
 CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 664cadb94..694b6373a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -540,6 +540,12 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
 endif()
 
+# GCC >= 12.1.0: Disable analysis on "maybe-uninitialized" variables because of the high false-positive rate
+if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-maybe-uninitialized")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
+endif()
+
 if(CMAKE_C_COMPILER_ID MATCHES "GNU")
   # Increase inlining limit to allow gcc compilation on e.g. RPi2
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --param large-function-growth=1600")
-- 
2.36.1