public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94911] New: Failure to optimize comparisons of VLA sizes
@ 2020-05-01 21:04 gabravier at gmail dot com
  2020-05-01 21:40 ` [Bug tree-optimization/94911] " glisse at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gabravier at gmail dot com @ 2020-05-01 21:04 UTC (permalink / raw)
  To: gcc-bugs

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++.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-13 12:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 21:04 [Bug tree-optimization/94911] New: Failure to optimize comparisons of VLA sizes gabravier at gmail dot com
2020-05-01 21:40 ` [Bug tree-optimization/94911] " glisse at gcc dot gnu.org
2020-05-01 22:10 ` pinskia at gcc dot gnu.org
2020-05-01 22:21 ` pinskia at gcc dot gnu.org
2020-05-01 22:35 ` glisse at gcc dot gnu.org
2023-05-13  5:04 ` pinskia at gcc dot gnu.org
2023-05-13 12:25 ` gabravier at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).