AshwinBanwari's blog

By AshwinBanwari, history, 3 years ago, In English

https://mirror.codeforces.com/contest/678/submission/128786847

With C++17, passing the an int into a function(lcm) which accepts a long long for some reason does not cast it to a long long but keeps it as an int. Then, unsurprisingly after being multiplied with another large int, it overflows.

On C++14 which I compiled locally initially, the int was implicitly converted to long long as expected and my solution worked.

Does anyone know why this is happening? I played around with gdb and compiling using C++17 and my gdb just went haywire once I entered the lcm function with the long long parameter.

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

Update: It turns out in c++17, there is std::lcm (and also std::gcd) which was being called instead of my own functions. The stdlib func returned an int since both params were ints.