MTC added a comment. In https://reviews.llvm.org/D52949#1268640, @xbolva00 wrote:
> Second thought, I don't think we should recommend std::size here (maybe it > should be okay for clang static analyzers) > > uint32_t data[] = {10, 20, 30, 40}; > len = sizeof(data)/sizeof(*data); // "warn" on valid code to recommend > std::size? I dont agree with such behaviour. IMHO, a clang-tidy checker is more suitable than clang static analyzer to indicate to the developers that we should prefer `std::size` to `sizeof(data)/sizeof(*data)`. What I want to know most is whether we should emit a warning for the code below. I haven't been able to test the patch yet, but intuitively, this patch will emit a warning. int foo(int *p) { int d = sizeof(p) / sizeof(char); // Should we emit a warning here? return d; } GCC keep silent about this case, and I agree with it, see https://gcc.godbolt.org/z/ZToFqq. What do you think about this case? https://reviews.llvm.org/D52949 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits