https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94911
Bug ID: 94911
Summary: Failure to optimize comparisons of VLA sizes
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
inline void assume(_Bool b)
{
if (!b)
__builtin_unreachable();
}
_Bool f(int n)
{
assume(n >= 1);
typedef int A[n];
++n;
A a;
int b[n];
n -= 2;
typedef int C[n];
C c;
return (sizeof(a) < sizeof(b)) && (sizeof(a) > sizeof(c));
}
This C code (this will have different results in C++ with GCC) should always
`return true`. LLVM makes this transformation, but GCC does not.
Also, extra question, is the fact that this always returns `false` when
compiled as C++ normal ? Clang has it return `true` if compiled as C++.