gcc issues warning when using the tolower function along with an optimization
flag. This warning also happens in other versions of gcc apart from 4.4.2

gcc -std=c99 -pedantic -O2 -Wall -Wunreachable-code a.c

a.c:13: warning: will never be executed



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

int main(void)
{
    char A[50] = "";
    strcat(A, "Hello World!");

    int COUNT = 0;
    while(A[COUNT])
    {
        A[COUNT] = (char)(tolower(A[COUNT])); // this line issues warning
        COUNT++;
    }
    puts(A); // output: hello world!
    return 0;
}


-- 
           Summary: gcc issues warning with tolower function with
                    optimization flag
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joe dot bassis at gmail dot com


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

Reply via email to