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

José Luis García Pallero jgpallero@gmail.com
Mon Mar 7 10:07:00 GMT 2011


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!
*****************************************



More information about the Gcc-help mailing list