ironsoul's blog

By ironsoul, history, 8 years ago, In English

See this submission -> Click.

As you see, I got a runtime error because of "assert" function that I added while debugging my code. My array S is an array of pairs where second value is an index from (1..m). I can not understrand why my code is getting a runtime error. "assert(s[i].second <= m)" should be fine but it leads to an error. Why?

  • Vote: I like it
  • +1
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Look at the size of array a.

»
8 years ago, # |
  Vote: I like it +8 Vote: I do not like it

What is the undefined behavior of C++ here? The title is purely misleading.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Well, he is looking for an index in array, which doesn't exist. This leads to undefined behavior, doesn't it?