http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53277

             Bug #: 53277
           Summary: Warning using -Wconversion and -Ox in gcc 4.5, 4.6 and
                    4.7 but not in previous releases
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jgpall...@gmail.com


Hello:

In this example:

#include<stdlib.h>
#include<string.h>
int main() {
    strspn("hello","h");
    return 0;
}

I obtain the warning:

test.c:4:5: warning: conversion to ‘size_t’ from ‘int’ may change the sign of
the result [-Wsign-conversion]

using the order:

gcc -Wall -Wextra -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, 4.6 and 4.7 but not in previous releases.

This behavior appears too if I do some assign:

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


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

I think this is a bug

Cheers

Reply via email to