[Scummvm-devel] g++ 4.3 compiler flags

Johannes Schickel lordhoto at gmail.com
Wed Jun 4 22:36:03 CEST 2008


>> Another nifty warning added is -Wparentheses, which warns about non
>> obvious operator evaluation precedence and asks the developer (or
>> with -Werror he has)  to use parentheses to clarify it. This is
>> currently disabled by adding -Wno-parentheses to the compiler flags,
>> else one had to change large chunks of code too (I found warnings
>> like that in code from at least sound/ and scumm/ I didn't want to
>> fix all those either, since it's not always obvious what they want
>> to do :-), so I stopped checking. It also warns about using &&
>> inside of || blocks (see the gui/eval.cpp change I made). IMHO we
>> should think of enabling it again and ask the people with knowledge
>> about the specific code parts to fix the warnings for it, it should
>> be another pretty usefull warning, expecially when using bit wise
>> operators like |, & etc.
>
> Sounds like a useful warning to me.

I could try to collect all warnings and report them as a bug for each
engine and one for all code in common places maybe. So the authors
could check their code.

>> Some of you might have noticed I also added -Wno-empty-body, this
>> one would usually warn about for (int i = 0; i < 10; ++i); and
>> suggest to put a space before the ';' or add {}. That's quite
>> annoying IMHO, so I think it is safe to keep it disabled in the
>> future.
>
> Well, OTOH such code *is* a potential source code bugs. I usually
> prefer to have a return before the ";" or "{}", i.e. have it in two
> lines. We have had bugs caused by an extra unwanted ";" ...

Should be easy to change for me maybe I'll do that tomorrow then.

>> So maybe some of you got some ideas on which warnings we should have
>> enabled and which we should have disabled. And of course it would be
>> nice if the engine developers could fix those warnings for their
>> code if we enable them. So what do you guys think of it?
> I am all for fixing warnings, as long as it is sensible. However, i
> will not have any access to GCC 4.3 for the foreseeable future, so I
> won't be able to contribute myself (other than answering questions
> about pieces of code, maybe).

I only started to wonder about it since g++ 4.3 is now default on my
Debian/unstable box though. It was a bit annoying to see how I got
loads of screens with error messages ;-).

// Johannes




More information about the Scummvm-devel mailing list