ziangwan added a comment.

My bad. I omit these two test cases. I apologize for my carelessness.

Yes, this warning definitely is a duplicate of c++11 narrowing, *when the code 
actually uses initialization-list syntax. For example, the following code would 
issue duplicated warnings for now:

  float ff = {222222222222L};  
  long a = 222222222222L;
  float ffff = {a};

However, c++11 narrowing conversion does not handle these cases. It does not 
handle initialization without initialization-list syntax. It does not handle 
implicit conversion in expressions. It does not handle implicit conversion in 
argument passing as well.

  void test(float b) {}
  
  float f = 222222222222L; // no narrowing warning
  
  long a = 222222222222L;
  float fff = a; // warning
  float c = a + fff; // no narrowing warning of a from long to float
  
  test(a); // no narrowing warning

Handling extra cases allow us to sanity-check code that does not use 
initialization-list syntax or has implicit conversion in expressions. I believe 
it is a valuable addition. A fix would be to let 
`-Wimplicit-int-float-conversion` skip initialization-list syntax. The other 
way would to augment c++ narrowing. What do you guys think is the proper way?

I will continue work on this patch. Please don't panic.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64666/new/

https://reviews.llvm.org/D64666



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

Reply via email to