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

             Bug #: 52617
           Summary: -Wconversion does not work for strlen
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: mathieu.malate...@gmail.com


Hi,

  gcc -Wconversion does not work for strlen function. For example:


#include <string.h>

size_t my_strlen( const char *input )
{
  return strlen( input );
}

int main()
{
  int s1 = strlen("bla");
  int s2 = my_strlen("bla");
  return 0;
}


leads to:

$ gcc -Wconversion t.c
t.c: In function ‘main’:
t.c:11: warning: conversion to ‘int’ from ‘size_t’ may alter its value


Clearly one warning is missing (on line 10).

Thanks

Reply via email to