[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    Re: [PATCH] Reduce warnings with Apple clang in InsetMathScript.cpp
From:       Stephan Witt <st.witt () gmx ! net>
Date:       2021-07-16 17:01:42
Message-ID: D5E5DAE9-17D3-4D82-A4A1-634A68719B69 () gmx ! net
[Download RAW message or body]

Am 16.07.2021 um 18:37 schrieb Jean-Marc Lasgouttes <lasgouttes@lyx.org>:
> 
> 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.

Ha, that's funny.

In fact I think the clang generated proposal has the problem to make a "senior \
developer" wonder why we want to send a nullptr to the stream. So one has to decode \
the logic code flow again and again. But mine isn't much better. Perhaps your patch \
plus a dedicated comment is the optimum?

> 
> 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
> 
> <0001-Work-around-compilation-warning.patch>-- 
> lyx-devel mailing list
> lyx-devel@lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-devel

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic