[Bug c++/58093] Semi-bogus warning about narrowing conversions and variadic templates
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 6 13:03:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58093
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Nick Maclaren from comment #0)
> 4.13 [conv.rank], 4.7 [conv.integral] and 5 [expr] make it pretty clear
> that this is not a narrowing conversion, which makes the diagnostic very
> confusing. I agree that it potentially changes value, but the wording
> could be better (e.g. 'loss of sign'). That's the trivial part of this
> report.
8.5.4 [dcl.init.list] p7 makes it very clear it *is* a narrowing conversion,
because the elements in the pack expansion Dims... are not constant
expressions.
> The more serious (but still minor) one is that I don't think that this
> is a soluble problem for the variadic template writer. It is unreasonable
> to have to convert arguments explicitly, when it's automatic under almost
> all circumstances.
Why is it not soluble? The solution is trivial:
size_t r[] = {static_cast<size_t>(Dims)...};
Or replace the static_cast with your preferred choice of cast.
G++ is following the standard, this is not a bug.
> size_t r[] = {Dims...};
> for (int i = 0; i < sizeof...(Dims); ++i)
> std::cout << " " << r[i];
This would be simpler as:
size_t r[] = {Dims...};
for (auto i : r)
std::cout << " " << i;
More information about the Gcc-bugs
mailing list