STL_MSFT added a comment.

I checked, and Clang 3.8.0 behaves identically to C1XX in the pair scenario. 
Here's the test case:

  #include <utility>
  
  template <typename A, typename B> struct Pair {
      A a;
      B b;
      
      template <typename X, typename Y> Pair(X&& x, Y&& y) : 
a(std::forward<X>(x)), b(std::forward<Y>(y)) { }
  };
  
  int main() {
      Pair<short, short> p(11, 22);
      return p.a == 11 && p.b == 22 ? 0 : 1;
  }

With `-Wconversion`, this emits:

  prog.cc:7:62: warning: implicit conversion loses integer precision: 'int' to 
'short' [-Wconversion]
      template <typename X, typename Y> Pair(X&& x, Y&& y) : 
a(std::forward<X>(x)), b(std::forward<Y>(y)) { }
                                                              
~^~~~~~~~~~~~~~~~~~
  prog.cc:11:24: note: in instantiation of function template specialization 
'Pair<short, short>::Pair<int, int>' requested here
      Pair<short, short> p(11, 22);
                         ^
  prog.cc:7:85: warning: implicit conversion loses integer precision: 'int' to 
'short' [-Wconversion]
      template <typename X, typename Y> Pair(X&& x, Y&& y) : 
a(std::forward<X>(x)), b(std::forward<Y>(y)) { }
                                                                                
     ~^~~~~~~~~~~~~~~~~~

So, if you were compiling your tests with `-Wconversion` and not suppressing 
warnings in "system headers", you'd see this in libc++ too.


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