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