I have an array of POD structs and am trying to sum across one field. Here\'s a minimal example:
struct Item
{
int x = 0;
int y = 0;
};
typedef Item It
As described by Richard Biener in my bug report, the problem seems to be that GCC prior to version 8 failed to understand that a field of a class or struct was subject to the same optimizations (e.g. constant loop count) as a regular variable. So it would emit all sorts of fancy code to optimally loop an unknown number of times, even when it was known at compile time, in the case where the container was a member variable.
The way I understand it, this bug probably affects quite a bit of code in the wild--e.g. anywhere a member small array is the subject of a C++11 range-based for loop.
Thanks to Richard Biener for the prompt resolution (targeted for GCC 8).