In a declaration like: enum { a = 0x80000000, b = -1, } the underlying type should be long and b's value should be 0xffffffffffffffff (on a 64-bit machine) but is 0xffffffff. The fix is in cast_enum_list() to change the the type of the enumeration after casting its value and not before since the original type is needed for the cast. This series is also available at: git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git fix-enum-sign-extend Dan Carpenter (1): fix sign extension in casting enums Luc Van Oostenryck (2): add test for enum sign extension remove useless optimization in cast_enum_list() parse.c | 4 +--- validation/enum-sign-extend.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 validation/enum-sign-extend.c -- 2.23.0