blitzkrieg639's blog

By blitzkrieg639, history, 5 years ago, In English

Hello everyone, can somebody please tell if there is some issue with the recently added GNU G++17 9.2.0(64 bit, msys 2) compiler? Because it costed me 3 wrong submissions and 10 minutes of time in yesterday's contest. I was submitting the code to the 2nd answer and it gave me WA 3 times, before I changed the compiler to GNU G++17(7.3.0) and it got accepted.

And this is not the first time, this has happened quite a lot of times.

Hence, I wanted to know, if something needs to be imparted into my code, before submitting using that compiler or is it just because of that compiler. Thank you, in advance!

  • Vote: I like it
  • -21
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

if (*lower_bound(a, a + n, x) == x)

I think this is undefined if lower_bound() returns a+n.

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

    Yes, it will, if x is not found, I think. If that is the problem, why other compilers are not reporting it?

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

      Undefined behaviour is literally that, undefined. It can give the correct answer, wrong answer, time out, erase your hard disk, anything. Always beware.

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

      The return of lower_bound() is ok, but that array is not initialized at position n. There can be x or any other value.