Le 16/07/2021 à 18:24, Stephan Witt a écrit :
Hi Thibaut,
the Apple clang compiler spits warnings for InsetMathScript.cpp:
Hi Stephan,
I was about to push the following patch :) I'll let you decide what to do.
JMarc
/Users/lyx/Development/lyx/src/mathed/InsetMathScript.cpp:619:11: warning:
variable 'tag' is used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]
else if (d)
^
/Users/lyx/Development/lyx/src/mathed/InsetMathScript.cpp:622:13: note:
uninitialized use occurs here
ms << MTag(tag);
^~~
/Users/lyx/Development/lyx/src/mathed/InsetMathScript.cpp:619:7: note: remove
the 'if' if its condition is always true
else if (d)
^~~~~~
/Users/lyx/Development/lyx/src/mathed/InsetMathScript.cpp:614:18: note:
initialize the variable 'tag' to silence this warning
const char * tag;
^
= nullptr
The attached patch makes it happy. It avoids the superfluous test for the bool
d but I left it in comment to make the logic clear. Do you like it?
BR, Stephan
>From e1f627939a950cd385f87b45661b17b4ffbb9f37 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri, 16 Jul 2021 18:27:15 +0200
Subject: [PATCH] Work around compilation warning
Clang 12 (at least) misses the fact that tag is always initialized,
because the if/else sequence does cover all cases.
Initialize the variable although it is not required. It does not hurt
at least.
---
src/mathed/InsetMathScript.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 9f391f66f9..a5f286b3a5 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -611,7 +611,7 @@ void InsetMathScript::mathmlize(MathMLStream & ms) const
if (!d && !u)
return;
- const char * tag;
+ const char * tag = nullptr;
if (u && d)
tag = has_limits ? "munderover" : "msubsup";
else if (u)
--
2.30.2
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel