Re: Strange warning about passing argument with different width due to prototype with gcc 4.4.0 on 64 bits machine

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

 



José Luis García Pallero <jgpallero@xxxxxxxxx> writes:

> As a curiosity, gcc 4.5.1 compiled by myself for my ppc debian emits a
> warning of the type "conversion to size_t from int may change the
> sign" for the code
>
> size_t var=0;
> var = strspn("hello","lo");
> var = (size_t)strspn("hello","lo");
>
> where strspn returns a size_t type
> (http://linux.die.net/man/3/strspn). The warning appears in both
> cases. But the warning only appears with the flag -Wconversion
> combined with -O3/-O2 or -O1 optimizations. Apparently, in this
> version some warnings depends on the level of optimization.
> Attached I send the example files

I would guess that on your system strspn is a macro when you compile
with optimization.  Try using the --save-temps option with -O and look
at what your call to strspn turns into.  Something in the expanded macro
is triggering the warning.

Ian



[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