On 3/17/21 2:36 AM, Jakub Jelinek wrote:
On Tue, Mar 16, 2021 at 06:28:46PM -0600, Martin Sebor via Gcc-patches wrote:
It seems sort of "inverted:" I'd expect OEP_LEXICOGRAPHIC on its
own to do a lexicographical comparison, without having to set
an additional bit to ask for it. If a more refined form of
The new flag is really orthogonal to what OEP_LEXICOGRAPHIC does and
for the VLA checks you are using OEP_LEXICOGRAPHIC for I think you exactly
don't want that behavior, both a and b when they are a union members
with the same type will actually have the same value at least in the way
GCC implements unions, so you want to treat them the same.
The same thing can be said about the case you're changing:
the ternary expression does evaluate to a reference to the same
subobject. Whether or not it's worth considering as a potential
mistake is a judgment call that may or may not be different for
different warnings.
The flag can also be called OEP_COMPONENT_REF_SAME_FIELD or whatever,
the reason for using the name I've used is just in case -Wduplicate-branches
will need another tweak in the future somewhere else, we don't have enough
bits to allocate for each detail separately.
I do think a different name than OEP_DUPLICATE_BRANCHES would be
preferable, one that describes what the flag does and not where
it's used. (Doing otherwise would suggest that every client of
the function have its own bit, even if has the same value as
an existing bit.)
As an aside, would a COMPONENT_REF and MEM_REF with the same base
object, offset, and type be considered the same?
Martin
Jakub