Where did the warning go?
Eivind LM
eivliste@online.no
Wed Feb 25 00:37:00 GMT 2009
On Tue, 24 Feb 2009 18:52:32 +0100, Ian Lance Taylor <iant@google.com>
wrote:
> "Eivind LM" <eivliste@online.no> writes:
>
>> It does of course depend on each case whether a warning is easy to
>> avoid or not, and also if it warns about a real problem or not. But
>> in any case, a warning can help me write code that more surely will
>> do what I intend. For example the following code is not doing what I
>> intended:
>>
>> #include <stdio.h>
>> void print(int a) { printf("%d\n", a); };
>> int main() { print(2.5); return 0; };
>>
>> I think the problem in the code is both easy to avoid and serious, but
>> I get no warning with -Wall and -Wextra (g++ 4.3).
>>
>> Instead of adding -Wconversion (and to search for any other flags I
>> might find useful, but that I don't know of yet), I would rather
>> compile my project with something like "-Weverything" from the
>> beginning, and then disable the warnings that turns out to not fit my
>> programming style.
>
> I think the issue here is that there is disagreement about whether the
> -Wconversion warnings rise to the level of being questionable. It would
> be reasonable to propose having -Wconversion under -Wall, if you want to
> send in a proposed patch. It might be interesting to try building some
> packages with such a change, notably gcc itself.
Maybe everything implied with -Wconversion is too much. But the code above
gave me a warning with g++ 4.1 (even without any flags to g++ at all). So
seems like these kinds of warnings are not new as defaults to gcc.
However, seems like 4.1 without flags gives less warnings than 4.3 with
the -Wconversion flag, so it might seem like only parts of -Wconversion
were included in 4.1.
For example this statement needs -Wconversion with 4.1 to create a warning:
float b = 123456789000;
So maybe I'm asking for only parts of -Wconversion to be included in
-Wall. Anyway, I'm afraid I will have to climb a few more steps in C
before I'm ready to submit patches to gcc :) Thanks for listening to my
opinions anyway.
Eivind
More information about the Gcc-help
mailing list