https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122881
Bug ID: 122881
Summary: `specified bound depends on the length of the source
argument` warning is too sensitive to order of
operands of MIN_EXPR
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Created attachment 62927
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62927&action=edit
Reduced testcase
Take the attached testcase (which is reduced from
c-c++-common/Wstringop-overflow.c).
Try with and without -fno-tree-reassoc. The only different that makes for the
IR is:
_8 = MIN_EXPR <_2, _1>;
vs:
_8 = MIN_EXPR <_1, _2>;
Where _2 is the strlen call stmt and _1 is not.
The warning only happens in the case of _2 being the first operand.
I found this as I was fixing reassociation to do the canonical form which is _1
first. That is reassoc should not have touched this MIN_EXPR but currently it
does and that allowed for the warning (only on accident).