79670478

Date: 2025-06-18 10:47:22
Score: 1
Natty:
Report link

Kudos to Christophe who brought up MISRA C++ rule "An array passed as a function argument shall not decay to a pointer", which led me to find that clang-tidy and Microsoft have already implemented this check.

> clang-tidy f.cpp -checks=-*,cppcoreguidelines-pro-bounds-array-to-pointer-decay -- -std=c++20
65 warnings and 1 error generated.
B:\f.cpp:25:13: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
   25 |         PrintArray(arr);
      |                    ^
Suppressed 64 warnings (64 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).

and Visual Studio

Visual Studio

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Jason Cho