STL_MSFT added a comment.

I can't possibly defend C1XX's behavior in your foo() scenario - but the pair 
scenarios being fixed here are different. pair<A, B>'s constructor from (X&&, 
Y&&) is perfect forwarding, so while the compiler can see that literals are 
being passed to (int&&, int&&), when it instantiates the constructor's 
definition, it just sees short being constructed from a perfectly-forwarded 
int, and warns about truncation there. C1XX doesn't attempt to "see through" 
the function call and notice that the arguments were literals. Its behavior is 
arguably desirable because the instantiation happens once per TU, and yet there 
may be other calls that are passing runtime-valued ints.

I chose static_cast<short> here because it was non-invasive, although ugly. 
There's a more invasive but prettier possibility - change the shorts to longs 
so that widening instead of truncation happens. I could do that if you want.


https://reviews.llvm.org/D27540



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to