public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
@ 2011-06-05 14:25 José Luis García Pallero
  2011-06-05 14:45 ` Marc Glisse
  2011-06-06 10:01 ` Ian Lance Taylor
  0 siblings, 2 replies; 12+ messages in thread
From: José Luis García Pallero @ 2011-06-05 14:25 UTC (permalink / raw)
  To: gcc-help

Hello,
Three months ago I sent this mail to gcc-help:

http://gcc.gnu.org/ml/gcc-help/2011-03/msg00064.html

The behavior in gcc 4.6 release persists. I don't know if it is a bug
exactly (in the original mail, some says that is a bug and some no).

Thanks

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-06-05 14:25 Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases José Luis García Pallero
@ 2011-06-05 14:45 ` Marc Glisse
  2011-06-05 16:03   ` José Luis García Pallero
  2011-06-06 10:01 ` Ian Lance Taylor
  1 sibling, 1 reply; 12+ messages in thread
From: Marc Glisse @ 2011-06-05 14:45 UTC (permalink / raw)
  To: José Luis García Pallero; +Cc: gcc-help

On Sun, 5 Jun 2011, José Luis García Pallero wrote:

> Hello,
> Three months ago I sent this mail to gcc-help:
>
> http://gcc.gnu.org/ml/gcc-help/2011-03/msg00064.html
>
> The behavior in gcc 4.6 release persists. I don't know if it is a bug
> exactly (in the original mail, some says that is a bug and some no).

There is no shame in filing a bug report without being absolutely certain.

In this case you could file one for gcc asking to improve the warning 
(casting the constant 0 won't change its sign...), and one against glibc 
asking that they explicitly cast 0 to size_t, after looking a bit if you 
can find anything similar already reported. I am not saying either change 
will happen, but it seems like a resonable strategy. And you may get 
interesting comments on the bug reports.

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-06-05 14:45 ` Marc Glisse
@ 2011-06-05 16:03   ` José Luis García Pallero
  2011-06-06  0:17     ` Marc Glisse
  0 siblings, 1 reply; 12+ messages in thread
From: José Luis García Pallero @ 2011-06-05 16:03 UTC (permalink / raw)
  To: gcc-help

El día 5 de junio de 2011 16:17, Marc Glisse <marc.glisse@inria.fr> escribió:
> On Sun, 5 Jun 2011, José Luis García Pallero wrote:
>
>> Hello,
>> Three months ago I sent this mail to gcc-help:
>>
>> http://gcc.gnu.org/ml/gcc-help/2011-03/msg00064.html
>>
>> The behavior in gcc 4.6 release persists. I don't know if it is a bug
>> exactly (in the original mail, some says that is a bug and some no).
>
> There is no shame in filing a bug report without being absolutely certain.
>
> In this case you could file one for gcc asking to improve the warning
> (casting the constant 0 won't change its sign...), and one against glibc
> asking that they explicitly cast 0 to size_t, after looking a bit if you can
> find anything similar already reported. I am not saying either change will
> happen, but it seems like a resonable strategy. And you may get interesting
> comments on the bug reports.

But the warning is about the strspn() function instead of return 0; sentence

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-06-05 16:03   ` José Luis García Pallero
@ 2011-06-06  0:17     ` Marc Glisse
  0 siblings, 0 replies; 12+ messages in thread
From: Marc Glisse @ 2011-06-06  0:17 UTC (permalink / raw)
  To: José Luis García Pallero; +Cc: gcc-help

On Sun, 5 Jun 2011, José Luis García Pallero wrote:

> El día 5 de junio de 2011 16:17, Marc Glisse <marc.glisse@inria.fr> escribió:
>> On Sun, 5 Jun 2011, José Luis García Pallero wrote:
>>
>>> Hello,
>>> Three months ago I sent this mail to gcc-help:
>>>
>>> http://gcc.gnu.org/ml/gcc-help/2011-03/msg00064.html
>>>
>>> The behavior in gcc 4.6 release persists. I don't know if it is a bug
>>> exactly (in the original mail, some says that is a bug and some no).
>>
>> There is no shame in filing a bug report without being absolutely certain.
>>
>> In this case you could file one for gcc asking to improve the warning
>> (casting the constant 0 won't change its sign...), and one against glibc
>> asking that they explicitly cast 0 to size_t, after looking a bit if you can
>> find anything similar already reported. I am not saying either change will
>> happen, but it seems like a resonable strategy. And you may get interesting
>> comments on the bug reports.
>
> But the warning is about the strspn() function instead of return 0; sentence

Then file the bug reports saying only what you understand. (the warning is 
about code in bits/string2.h)

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-06-05 14:25 Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases José Luis García Pallero
  2011-06-05 14:45 ` Marc Glisse
@ 2011-06-06 10:01 ` Ian Lance Taylor
  1 sibling, 0 replies; 12+ messages in thread
From: Ian Lance Taylor @ 2011-06-06 10:01 UTC (permalink / raw)
  To: José Luis García Pallero; +Cc: gcc-help

José Luis García Pallero <jgpallero@gmail.com> writes:

> Three months ago I sent this mail to gcc-help:
>
> http://gcc.gnu.org/ml/gcc-help/2011-03/msg00064.html
>
> The behavior in gcc 4.6 release persists. I don't know if it is a bug
> exactly (in the original mail, some says that is a bug and some no).

It's clearly a bug, we just don't know if it's a bug in gcc or a bug in
glibc.  Go ahead and file a bug report, or two.

Ian

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-03-08  0:41         ` Ian Lance Taylor
@ 2011-03-08  7:30           ` José Luis García Pallero
  0 siblings, 0 replies; 12+ messages in thread
From: José Luis García Pallero @ 2011-03-08  7:30 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Cedric Roux, gcc-help

El día 8 de marzo de 2011 01:41, Ian Lance Taylor <iant@google.com> escribió:
> José Luis García Pallero <jgpallero@gmail.com> writes:
>
>> El día 7 de marzo de 2011 15:28, Cedric Roux <cedric.roux@acri-st.fr> escribió:
>>>> 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.
>>>
>>> Because it's most certainly a bug.
>>
>> Can anyone upload a bug report to gcc bugzilla or gcc-bug mailing
>> list? I'm not subscribed
>
> It's not clear to me whether this is a gcc bug or a glibc bug.
>
> Consider the -fcond-mismatch option.

The warning does not disappear with -fcond-mismatch

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-03-07 22:02       ` José Luis García Pallero
@ 2011-03-08  0:41         ` Ian Lance Taylor
  2011-03-08  7:30           ` José Luis García Pallero
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Lance Taylor @ 2011-03-08  0:41 UTC (permalink / raw)
  To: José Luis García Pallero; +Cc: Cedric Roux, gcc-help

José Luis García Pallero <jgpallero@gmail.com> writes:

> El día 7 de marzo de 2011 15:28, Cedric Roux <cedric.roux@acri-st.fr> escribió:
>>> 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.
>>
>> Because it's most certainly a bug.
>
> Can anyone upload a bug report to gcc bugzilla or gcc-bug mailing
> list? I'm not subscribed

It's not clear to me whether this is a gcc bug or a glibc bug.

Consider the -fcond-mismatch option.

Ian

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-03-07 14:28     ` Cedric Roux
@ 2011-03-07 22:02       ` José Luis García Pallero
  2011-03-08  0:41         ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: José Luis García Pallero @ 2011-03-07 22:02 UTC (permalink / raw)
  To: Cedric Roux; +Cc: gcc-help

El día 7 de marzo de 2011 15:28, Cedric Roux <cedric.roux@acri-st.fr> escribió:
>> 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.
>
> Because it's most certainly a bug.

Can anyone upload a bug report to gcc bugzilla or gcc-bug mailing
list? I'm not subscribed

> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main() {
>  size_t x;
>  x = strspn("hello","h");
>  printf("%zd\n", x);
>  return 0;
> }
>
> warns too at -O, -O1, -O2, -O3 with -Wconversion. And the value is correctly
> used and so on.
>



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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-03-07 14:20   ` José Luis García Pallero
@ 2011-03-07 14:28     ` Cedric Roux
  2011-03-07 22:02       ` José Luis García Pallero
  0 siblings, 1 reply; 12+ messages in thread
From: Cedric Roux @ 2011-03-07 14:28 UTC (permalink / raw)
  To: José Luis García Pallero; +Cc: gcc-help

> 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.

Because it's most certainly a bug.

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
   size_t x;
   x = strspn("hello","h");
   printf("%zd\n", x);
   return 0;
}

warns too at -O, -O1, -O2, -O3 with -Wconversion. And the value is correctly used and so on.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-03-07 13:16 ` Marc Glisse
@ 2011-03-07 14:20   ` José Luis García Pallero
  2011-03-07 14:28     ` Cedric Roux
  0 siblings, 1 reply; 12+ messages in thread
From: José Luis García Pallero @ 2011-03-07 14:20 UTC (permalink / raw)
  To: gcc-help; +Cc: Marc Glisse

El día 7 de marzo de 2011 14:16, Marc Glisse <marc.glisse@inria.fr> 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@gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
  2011-03-07 10:07 José Luis García Pallero
@ 2011-03-07 13:16 ` Marc Glisse
  2011-03-07 14:20   ` José Luis García Pallero
  0 siblings, 1 reply; 12+ messages in thread
From: Marc Glisse @ 2011-03-07 13:16 UTC (permalink / raw)
  To: José Luis García Pallero; +Cc: gcc-help

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases
@ 2011-03-07 10:07 José Luis García Pallero
  2011-03-07 13:16 ` Marc Glisse
  0 siblings, 1 reply; 12+ messages in thread
From: José Luis García Pallero @ 2011-03-07 10:07 UTC (permalink / raw)
  To: gcc-help

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

The warning appears with -O, -O1, -O2 and -O3, but not with -O0. The
warning appears in gcc 4.5 and 4.6 but not in previous releases.
I'm using:

For gcc 4.5 series:

Debian GNU/Linux Sid
gcc 4.5.2 from Debian repos
Pentium M, 1.3 GHz

For gcc 4.6 series:

Red Hat Enterprise Linux 5
gcc 4.6.0 20110115 compiled by hand from http://gcc.gnu.org/
Intel Xeon X5650 2.67 GHz

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-06-06  5:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-05 14:25 Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases José Luis García Pallero
2011-06-05 14:45 ` Marc Glisse
2011-06-05 16:03   ` José Luis García Pallero
2011-06-06  0:17     ` Marc Glisse
2011-06-06 10:01 ` Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
2011-03-07 10:07 José Luis García Pallero
2011-03-07 13:16 ` Marc Glisse
2011-03-07 14:20   ` José Luis García Pallero
2011-03-07 14:28     ` Cedric Roux
2011-03-07 22:02       ` José Luis García Pallero
2011-03-08  0:41         ` Ian Lance Taylor
2011-03-08  7:30           ` José Luis García Pallero

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).