Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use c++11 for size test #3509

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions runtime/core/portable_type/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ class basic_string_view final {
}

constexpr const_reference at(size_type pos) const {
ET_CHECK_MSG(
pos >= size_,
"string_view::operator[] or string_view::at() out of range");
return at_(pos);
return (pos >= size_)
? (ET_ASSERT_MESSAGE_EMIT(
" (%s): "
"string_view::operator[] or string_view::at() out of range",
pos >= size_),
torch::executor::runtime_abort())
: at_(pos);
}

constexpr const_reference front() const {
Expand Down Expand Up @@ -137,9 +140,13 @@ class basic_string_view final {

constexpr basic_string_view substr(size_type pos = 0, size_type count = npos)
const {
ET_CHECK_MSG(
pos > size_, "basic_string_view::substr parameter out of bounds.");
return substr_(pos, count);
return (pos > size_)
? (ET_ASSERT_MESSAGE_EMIT(
" (%s): "
"basic_string_view::substr parameter out of bounds.",
pos > size_),
torch::executor::runtime_abort())
: substr_(pos, count);
}

constexpr int compare(basic_string_view rhs) const noexcept {
Expand Down
6 changes: 3 additions & 3 deletions test/build_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"
CXX_FLAGS="-Wno-gnu"
compiler=$(cc --version)
if [[ $compiler == *"clang"* ]]; then
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-extensions"
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-extensions -Wc++14-extensions"
elif [[ $compiler == *"cc"* ]]; then
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-compat"
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-compat -Wc++14-compat"
else
echo "Unknown compiler: $compiler"
exit 1
Expand All @@ -31,7 +31,7 @@ cmake_install_executorch_lib() {
rm -rf cmake-out

retry cmake -DBUCK2="$BUCK2" \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DCMAKE_INSTALL_PREFIX=cmake-out \
Expand Down