public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/99966] New: Bounds check not eliminated by assert
@ 2021-04-08  1:23 jmuizelaar at mozilla dot com
  2021-04-08  7:19 ` [Bug tree-optimization/99966] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jmuizelaar at mozilla dot com @ 2021-04-08  1:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99966

            Bug ID: 99966
           Summary: Bounds check not eliminated by assert
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jmuizelaar at mozilla dot com
  Target Milestone: ---

#include <cassert>
#include <cstdint>
#include <cstddef>
#include <vector>

uint64_t f(std::vector<uint64_t>& data, size_t start, size_t end){
    assert(start < end && start < data.size() && end <= data.size());


    uint64_t total = 0;
    for (size_t i = start; i < end; i++) {
        total += data.at(i);
    }
    return total;
}

https://godbolt.org/z/Ksecrec11

Clang is able to eliminate the the check when using -mllvm
-enable-constraint-elimination
https://godbolt.org/z/K67b8PTM9

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

end of thread, other threads:[~2022-11-28 22:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08  1:23 [Bug tree-optimization/99966] New: Bounds check not eliminated by assert jmuizelaar at mozilla dot com
2021-04-08  7:19 ` [Bug tree-optimization/99966] " rguenth at gcc dot gnu.org
2022-01-11 18:59 ` amacleod at redhat dot com
2022-11-03 19:31 ` amacleod at redhat dot com
2022-11-28 22:09 ` pinskia at gcc dot gnu.org

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