https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117700
--- Comment #4 from R. Diez <rdiez-2006 at rd10 dot de> --- I just found out some more information on this. C++ is counterintuitive here, as template ArrayElemCount is only actually using type information. This article considers it a language defect: https://www.learncpp.com/cpp-tutorial/stdarray-length-and-indexing/ That article mentions that this C++ language issue has been addressed in C++23 by P2280: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2280r4.html In the meantime, this C++11 implementation should do the trick. It uses a macro as an intermediate step, but I can live with it: https://brnz.org/hbr/?p=1491