[PATCH] [StaticAnalyzer] New checker Sizeof on expression
Daniel.Marjamaki at evidente.se
Wed Nov 27 08:54:35 PST 2013
>> Sure. I think it's even fine for a compiler warning, since sizeof(size_t) is a clearer way to get the same result.
> I know I'm a little late here, but I think the reason why you wouldn't want to use sizeof(size_t) is that you need to include certain standard library headers to pull in size_t, I.E. <cstddef>. The same goes for ptrdiff_t. Doing sizeof(sizeof(whatever)) frees you from that requirement.
To me it sounds like they prefer misleading code instead of an #include then. I wonder if you or anybody else here have seen such project. Or was it an idea when there could in theory be false positives?
I want to get this warning into clang. I wonder if it will make you happy if we only write the warning only when we see a #include anywhere in the file. If we see an #include then the project uses includes. Most real files include files so this heuristic wouldn't hurt the hit rate much imho.
More information about the cfe-commits