Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases

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

 



El día 7 de marzo de 2011 14:16, Marc Glisse <marc.glisse@xxxxxxxx> escribió:
> On Mon, 7 Mar 2011, José Luis García Pallero wrote:
>
>> Hello,
>> In this example:
>>
>> #include<stdlib.h>
>> #include<string.h>
>> int main() {
>>   strspn("hello","h");
>>   return 0;
>> }
>>
>> I obtain a warning as:
>>
>> test.c:4:5: warning: conversion to ‘size_t’ from ‘int’ may change the
>> sign of the result
>>
>> If I compile the program with the options:
>>
>> gcc -Wconversion -O test.c -o test
>
> Note that your example can be reduced to:
> int main() {
>        (0 ? ((void) (0), 0) : 1u) ;
>        return 0;
> }
>
> Not a most useful warning indeed...
>
>> The warning appears with -O, -O1, -O2 and -O3, but not with -O0.
>
> glibc includes different code when __OPTIMIZE__ is defined.
>
> --
> Marc Glisse
>

But why in previous gcc versions the warning didn't appears. And
strspn() is a common function in string.h. I don't understand why the
call to strspn() with correct arguments emits a warning.

-- 
*****************************************
José Luis García Pallero
jgpallero@xxxxxxxxx
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************



[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