This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix optimization regression in constant folder
> So I propose to define all sizetypes as having undefined overflow (the same
> as for pointers) as this will likely cause the least problems with mismatched
> semantics of involved types in expressions. If we do that we should see the
> optimization issues in C as well.
No you won't because people don't use variable-length arrays in C that much:
it's rare to see them *at all*. But it's not at all uncomon in real Ada
code to have a dozen or more variable-length arrays in a single record.
But I also don't understand why pointers and sizetypes should have anything
like similar properties. Sizetypes talk about sizes and offsets and
pointers talk about addresses: those seem very different to me.
As a pragmatic matter, the reason you want pointers to have undefined
overflow semantics are so that you don't lose loop optimizations when pointers
are used as bivs, which is very common while computations involving the
addition and subtraction of pointers don't get very complicated.
It's exactly the other way around for sizetypes: they aren't bivs, so
there's no advantage in having undefined overflow semantics, but they ARE
used in complex computations, where having wrapping semantics will allow