g++ Compiler flag to highlight bugs if (0 <= amplitudeH <= 1)

G

Guest

I've inherited code which contains loads of nasty bugs as above (I'd expect it to be if ((0 <= amplitudeH) && (amplitudeH<= 1)).

Is there any way for the compiler to warn of this ambiguous type of code?
 
F

Fred Zwarts \(KVI\)

wrote in message
I've inherited code which contains loads of nasty bugs as above (I'd expect
it to be if ((0 <= amplitudeH) && (amplitudeH<= 1)).

Is there any way for the compiler to warn of this ambiguous type of code?

For many years we have been very happy with FlexeLint
(http://www.gimpel.com). Although modern compilers start to be more
informative about such valid, but questionable use of language constructs,
they still do not beat FlexeLint.
 
M

Marc

I've inherited code which contains loads of nasty bugs as above (I'd expect it to be if ((0 <= amplitudeH) && (amplitudeH<= 1)).

Is there any way for the compiler to warn of this ambiguous type of code?

warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
(this comes by default with -Wall)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top