From e93f3f6812cb0fc413d618c940e1f1c48d6ba59d Mon Sep 17 00:00:00 2001
From: Andrew Heather <>
Date: Thu, 9 Jun 2022 11:56:26 +0100
Subject: [PATCH] COMP: Gcc 11+ potential fix - see #2434

---
 src/OpenFOAM/primitives/Tensor/TensorI.H | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H
index 4e8cb92c045..cb9fea259a6 100644
--- a/src/OpenFOAM/primitives/Tensor/TensorI.H
+++ b/src/OpenFOAM/primitives/Tensor/TensorI.H
@@ -641,6 +641,10 @@ operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
 
 
 template<class Cmpt>
+#if defined(__GNUC__) && !defined(__clang__)
+// Workaround for gcc (11+) that fails to handle tensor dot vector
+__attribute__((optimize("no-tree-vectorize")))
+#endif
 inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
 operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
 {
-- 
GitLab