Both gcc and clang generate strange/inefficient code

I ran into some surprisingly weird output of both Clang and gcc on a simple code snippet, and I thought I'd share it. Consider the following C++ function which, in a roundabout way, checks whether an std::array passed as an argument only contains zeros: #include <array> static constexpr int arraySize = 1; bool isAllZeros (const std::array<int, arraySize> &array) { std::array<int, arraySize>…