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]

 



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