https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123929
--- Comment #2 from Philipp Lucas <phdiv at fastmail dot fm> ---
(In reply to Andrew Pinski from comment #1)
> I am also not sure if this reduced testcase is represenative of the original
> code. Especially the wrapping code.
The real wrapping code is more like
struct IntWrap {
int i = -1;
explicit IntWrap(int);
operator int() const { return i; }
IntWrap& operator++() { ++i; return *this; }
};
The idea being that the wrapper can be used in place of an int, but not
an int in place of a wrapper, and that the wrapper is initialized to a
particular value. Changing the code to this does not change the outcome.
> getFloat is hidden so it could in theory increment i.i too.
Hm, when I replace getFloat with a simple array lookup the warning
disappears. But I don't think the possibility that getFloat const_casts
away the & and manipulates i.i warrants the very explicit warning
"arrayTags[i] = hasOption(i);".