Re: Implicit conversion from 32bits integer to 16bits integer (GCC 4.3.3)

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

 



2009/3/10 Frederic Belouin <frederic.belouin@xxxxxxxxx>:
> Hello,
>
> I would like to have a warning when there is an Implicit conversion in
> source code:

This is a question for gcc-help.

> uint32_t foo = 2000;
>
> uint16_t bar = foo;  //--> Warning Implicit conversion from uint32_t
> to uint16_t....
>
> uint16_t bar2= (uint16_t) foo; // --> no warning.
>
>
> I now that -Wtraditional-conversion in GCC 4.3.x is able to show this
> message,

It should not. Does it really? Can you provide a complete preprocessed testcase?

> but it also display warning for function implicit conversion:
> Is it possible to have only warning for implicit conversion for
> variable and not for prototype?

You did not understand what -Wtraditional-conversion does:

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

-Wtraditional-conversion (C and Objective-C only)
Warn if a prototype causes a type conversion that is different from
what would happen to the same argument in the absence of a prototype.

It means that, if there was no prototype for foobar, there would be a
type conversion different from what occurs given the prototype, and
that is what Wtraditional-conversion warns.

What you want is -Wconversion. http://gcc.gnu.org/wiki/NewWconversion

Cheers,

Manuel.


[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