Re: Where did the warning go?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 24 Feb 2009 18:52:32 +0100, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:

"Eivind LM" <eivliste@xxxxxxxxx> 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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux