Skip to content

Commit b0c0e30

Browse files
lucylqfacebook-github-bot
authored andcommitted
Use c++11 for size test (pytorch#3509)
Summary: Pull Request resolved: pytorch#3509 Reviewed By: mergennachin, swolchok Differential Revision: D57003591 Pulled By: lucylq fbshipit-source-id: 25f3a311260269761a890d898c6c4381f691cc21
1 parent f9db02a commit b0c0e30

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

runtime/core/portable_type/string_view.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ class basic_string_view final {
7979
}
8080

8181
constexpr const_reference at(size_type pos) const {
82-
ET_CHECK_MSG(
83-
pos >= size_,
84-
"string_view::operator[] or string_view::at() out of range");
85-
return at_(pos);
82+
return (pos >= size_)
83+
? (ET_ASSERT_MESSAGE_EMIT(
84+
" (%s): "
85+
"string_view::operator[] or string_view::at() out of range",
86+
pos >= size_),
87+
torch::executor::runtime_abort())
88+
: at_(pos);
8689
}
8790

8891
constexpr const_reference front() const {
@@ -137,9 +140,13 @@ class basic_string_view final {
137140

138141
constexpr basic_string_view substr(size_type pos = 0, size_type count = npos)
139142
const {
140-
ET_CHECK_MSG(
141-
pos > size_, "basic_string_view::substr parameter out of bounds.");
142-
return substr_(pos, count);
143+
return (pos > size_)
144+
? (ET_ASSERT_MESSAGE_EMIT(
145+
" (%s): "
146+
"basic_string_view::substr parameter out of bounds.",
147+
pos > size_),
148+
torch::executor::runtime_abort())
149+
: substr_(pos, count);
143150
}
144151

145152
constexpr int compare(basic_string_view rhs) const noexcept {

test/build_size_test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"
1717
CXX_FLAGS="-Wno-gnu"
1818
compiler=$(cc --version)
1919
if [[ $compiler == *"clang"* ]]; then
20-
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-extensions"
20+
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-extensions -Wc++14-extensions"
2121
elif [[ $compiler == *"cc"* ]]; then
22-
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-compat"
22+
CXX_FLAGS="$CXX_FLAGS -Werror -Wc++17-compat -Wc++14-compat"
2323
else
2424
echo "Unknown compiler: $compiler"
2525
exit 1
@@ -31,7 +31,7 @@ cmake_install_executorch_lib() {
3131
rm -rf cmake-out
3232

3333
retry cmake -DBUCK2="$BUCK2" \
34-
-DCMAKE_CXX_STANDARD=14 \
34+
-DCMAKE_CXX_STANDARD=11 \
3535
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
3636
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
3737
-DCMAKE_INSTALL_PREFIX=cmake-out \

0 commit comments

Comments
 (0)