https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80157
Bug ID: 80157 Summary: Spurious "Wsign-conversion" warning with const, size_t, array. Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ian at geometrian dot com Target Milestone: --- Minimal example (compile GCC >= ~6.1 with -Wsign-conversion): #include <cstdlib> bool f(size_t const xy[2], int z) { return xy[0] + xy[1] < static_cast<size_t>(z); } Produces an erroneous warning: <source>: In function 'bool f(const size_t*, int)': <source>:3:25: warning: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Wsign-conversion] return xy[0] + xy[1] < static_cast<size_t>(z); ^~~~~~~~~~~~~~~~~~~~~~ Compiler exited with result code 0 Taking the const out, using unsigned, or passing x and y separately rather than as an array resolves the warning. Doesn't occur on Clang, MSVC, or earlier GCC. May be related to bug 66170.