https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88566
Bug ID: 88566 Summary: -Wconversion not using value range information Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hoganmeier at gmail dot com Target Milestone: --- https://godbolt.org/z/p0RMde unsigned char foo(uint8_t pin) { if (pin >= 3 && pin <= 6) return pin - 2; if (pin >= 9 && pin <= 10) return pin - 4; if (pin >= 20 && pin <= 23) return pin - 13; return 0; } $ gcc -O3 -Wconversion -S <source>:5:39: warning: conversion from 'int' to 'uint8_t' {aka 'unsigned char'} may change value [-Wconversion] 5 | if (pin >= 3 && pin <= 6) return pin - 2; | ~~~~^~~ gcc should be aware that the value is well within the uint8_t range.