https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116780
--- Comment #16 from Georg-Johann Lay <gjl at gcc dot gnu.org> --- (In reply to Segher Boessenkool from comment #15) > It makes sense never, not on any target, not with LRA nor without. Though there are test cases that are UB and valid as I just learned some weeks ago. When I came across gcc.dg/signbit-6.c https://gcc.gnu.org/pipermail/gcc/2024-October/244903.html Quote: > > So as far as I can see, that test has at least 3 bugs? > > > > 1) Missing -fwrapv so that -INT_MIN is no more UB, hence the > > test would assert that a[0] == b[0]. > > That's not a bug. This is the test case: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/testsuite/gcc.dg/signbit-6.c;h=3a522893222d067eb68e242e48789b2f919fbebb;hb=HEAD#l40 Line 40 ff. lead to -INT_MIN *without* -fwrapv or similar. > 41 /* This will invoke UB due to -INT32_MIN. The test is supposed to pass > 42 because GCC is supposed to handle this UB case in a predictable way. */ > 43 a[0] = INT32_MIN; > 44 b[0] = INT32_MIN; That comment was added by myself. According to Tamar, this UB test case was explicitly requestet during the review for some new feature / new optimization. > The INT_MIN case was added because it was a concern during review. https://gcc.gnu.org/pipermail/gcc/2024-October/244905.html To make a long story short, there are cases where GCC is handling UB in a predictable / testable way. Similar should be achievable with the test case in the current PR: -------------------------------------------------------- The frame size is known at compile time, and the compiler / LRA is accessing a location outside that area with an addressing mode (SP+const or FP+const) that could easily be checked and diagnosed. Now as a user, I would prefer current LRA behaviour (ice-on-invalid-code) over Reload's (everything seems to be fine). But on the other hand, ICEs don't look very professional... > It makes sense never, not on any target, not with LRA nor without. So ice-on-invalid-code then. > It is incorrect according to 6.7.6.2/1 already ("If the expression is a > constant > expression, it shall have a value greater than zero.") Arrays of size zero are GNU-C addition. But as far as I understand, when a zero-sized array doesn't occur in a structure, or when it is the only element in a struct, then accesses are invalid. https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html