[Bug libstdc++/107092] std::for_each_n and its friends incorrectly accept size parameters that are not convertible to an integer type
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Sep 30 10:54:02 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107092
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2022-09-30
Status|UNCONFIRMED |NEW
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The reason I added overloads for floating-point types is that they can be
converted to integral types. But if you read "is convertible to **an** integral
type" as meaning unambiguously convertible to exactly one integral type, then
that's not true for FP types.
I did add tests for PR 87982 that FP types can be used, but I don't think there
were any pre-existing tests, and maybe nobody needs that.
I could retain support for real FP types, but reject your testcase, like this:
constexpr long long
__size_to_integer(floating_point auto __n) { return (long long)__n; }
But maybe I should just drop the FP overloads.
More information about the Gcc-bugs
mailing list