This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58093] Semi-bogus warning about narrowing conversions and variadic templates
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Aug 2013 13:03:07 +0000
- Subject: [Bug c++/58093] Semi-bogus warning about narrowing conversions and variadic templates
- Auto-submitted: auto-generated
- References: <bug-58093-4 at http dot gcc dot gnu dot org/bugzilla/>
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;