[Bug c++/86190] [6/7/8/9 Regression] -Wsign-conversion ignores explicit conversion in some cases
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 18 11:59:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86190
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Further reduced:
typedef unsigned long size_t;
struct vector {
typedef size_t size_type;
size_type size();
};
bool func(vector vec, int var)
{
return vec.size() < static_cast<size_t>(var);
}
sc.cc: In function 'bool func(vector, int)':
sc.cc:10:23: warning: conversion to 'vector::size_type {aka long unsigned int}'
from 'int' may change the sign of the result [-Wsign-conversion]
return vec.size() < static_cast<size_t>(var);
^~~~~~~~~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list