Q_ASSERT(false) in else branch gives compiler warning

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Q_ASSERT(false) in else branch gives compiler warning

heuchi
Hi everybody,

after Werner's change to fix compilation with Qt5.5 I'm getting warnings like
this:

/home/joern/MuseScoreQt55/libmscore/element.cpp: In member function ‘virtual
QPointF Ms::Element::pagePos() const’:
/home/joern/MuseScoreQt55/libmscore/element.cpp:520:34: warning: suggest
braces around empty body in an ‘else’ statement [-Wempty-body]
                   Q_ASSERT(false);
                                  ^

This "Q_ASSERT(false);" was introduced in 3adc1ea6 by Jojo-Schmitz in March
2014 to replace "abort();"

As far as I understand, it means that the current release will silently ignore
a problem that used to abort the  application and I was just wondering if this
is the desired behaviour.

On the other hand, it seems to not have been a problem for some time now, so
we might just want to get rid of the warning.

heuchi


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer
Reply | Threaded
Open this post in threaded view
|

Re: Q_ASSERT(false) in else branch gives compiler warning

Maurizio M. Gavioli
heuchi wrote
after Werner's change to fix compilation with Qt5.5 I'm getting warnings like this:

/home/joern/MuseScoreQt55/libmscore/element.cpp: In member function ‘virtual QPointF Ms::Element::pagePos() const’:
/home/joern/MuseScoreQt55/libmscore/element.cpp:520:34: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
                   Q_ASSERT(false);
                                  ^
I assume you get this warning while compiling in release mode; Q_ASSERT() does something only in debug mode, in release, it is results in no code (whence the warning for the 'empty' else). I would assume this was the intended behaviour, when the original "abort()" has been replaced with "Q_ASSERT()".

Whether it is the right thing to do in this specific case, I cannot say.

M.
Reply | Threaded
Open this post in threaded view
|

Re: Q_ASSERT(false) in else branch gives compiler warning

Jojo-Schmitz

The intention was, I think, to replace the  abort() by assert() and hence indeed only affect debug builds, but in a Qt fashion.

Bye, Jojo



---- Maurizio M. Gavioli schrieb ----

heuchi wrote
> after Werner's change to fix compilation with Qt5.5 I'm getting warnings
> like this:
>
> /home/joern/MuseScoreQt55/libmscore/element.cpp: In member function
> ‘virtual QPointF Ms::Element::pagePos() const’:
> /home/joern/MuseScoreQt55/libmscore/element.cpp:520:34: warning: suggest
> braces around empty body in an ‘else’ statement [-Wempty-body]
>                    Q_ASSERT(false);
>                                   ^

I assume you get this warning while compiling in release mode; Q_ASSERT()
does something only in debug mode, in release, it is results in no code
(whence the warning for the 'empty' else). I would assume this was the
intended behaviour, when the original "abort()" has been replaced with
"Q_ASSERT()".

Whether it is the right thing to do in this specific case, I cannot say.

M.



--
View this message in context: http://dev-list.musescore.org/Q-ASSERT-false-in-else-branch-gives-compiler-warning-tp7579451p7579452.html
Sent from the MuseScore Developer mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer