[Bug middle-end/85929] New: _GLIBCXX_ASSERTIONS, subscript type mismatch, and std::vector bounds check elimination
fw at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri May 25 19:40:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85929
Bug ID: 85929
Summary: _GLIBCXX_ASSERTIONS, subscript type mismatch, and
std::vector bounds check elimination
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: fw at gcc dot gnu.org
Target Milestone: ---
Compile this with “gcc -O2” on a 64-bit platform:
#define _GLIBCXX_ASSERTIONS
#include <vector>
typedef unsigned int size_type;
void
increment (std::vector<double> &vec)
{
size_type count = vec.size();
for (size_type i = 0; i < count; ++i)
vec[i] += 1;
}
The expectation is that there is no call to abort. The bounds check is
optimized away if the (global) size_type is itself size_t/unsigned long
(matching the index type of the vector).
A loop like this appears in the dealII benchmark from SPEC2006, and it is a
major source of performance regression with _GLIBCXX_ASSERTIONS.
More information about the Gcc-bugs
mailing list