File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed
test/problems/hellounix/submissions/run_time_error Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -15,19 +15,10 @@ const size_t mb = 513;
15
15
16
16
template <typename T>
17
17
T use (std::vector<T>& todo) {
18
- // init with some data
19
- for (std::size_t i = 0 ; i < todo.size (); i++) todo[i] = T (i % 7 );
20
- // do some computation that needs the memory
21
- for (int k = 0 ; k < 7 ; k++) {
22
- for (std::size_t i = 0 ; i < todo.size (); i++) {
23
- std::size_t j = (i + todo[i]) % todo.size ();
24
- todo[j] = (todo[i] % 7 ) + (todo[j] % 7 );
25
- }
26
- }
27
- // accumulate the result
28
- T res = 0 ;
29
- for (auto x : todo) res = (res >> 1 ) + (x >> 1 );
30
- return res;
18
+ if (todo.empty ()) return {};
19
+ volatile T* p = &to_use[0 ];
20
+ // reading a volatile pointer is a side effect and cannot be optimized
21
+ return p[0 ];
31
22
}
32
23
33
24
int main () {
You can’t perform that action at this time.
0 commit comments