https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83407

            Bug ID: 83407
           Summary: Warn about unsigned size_t underflow
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

Could GCC warn about this?

I expected
main.c:8:4: error: size_t underflow 'result'




//gcc -O2 -Wall -Wextra -Wpedantic -o main main.c

#include <stdio.h>

int main (void)
{
    size_t value = 0;
    size_t result = value - 1;

    printf("result: %zu\n", result);

    return 0;
}

Reply via email to