Code Monkey home page Code Monkey logo

Comments (12)

error256 avatar error256 commented on July 29, 2024 1

https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
Compiling with -fsanitize=return should help too.

from codewars-runner-cli.

kazk avatar kazk commented on July 29, 2024

Looks like the -O2 flag that was added is messing with the test framework. If I remove that flag, the test fails the same way as C++14 version with exit code 132 (Illegal Instruction).

For "Last digit of a huge number", solution without body crashes in random tests (segfaults).

from codewars-runner-cli.

g964 avatar g964 commented on July 29, 2024

For "Last digit of a huge number", solution without body crashes in random tests (segfaults).

But passes "TEST".

from codewars-runner-cli.

kazk avatar kazk commented on July 29, 2024

I know, I'm just listing my observations. It seems to be caused by -O2 flag like I wrote above.

from codewars-runner-cli.

error256 avatar error256 commented on July 29, 2024

Not returning a value from a function is undefined behavior, which gives the compiler freedom to do anything, not necessarily to return an unspecified value, so, apparently, the function has been optimized to always return what is expected (and Clang is known for sophisticated optimization as in famous https://kristerw.blogspot.com/2017/09/why-undefined-behavior-may-call-never.html). So it's not like something is wrong with the framework. I'm not sure what can be done about it though...

from codewars-runner-cli.

g964 avatar g964 commented on July 29, 2024

Amongst the kata I tried some pass and some rightly fail.

from codewars-runner-cli.

kazk avatar kazk commented on July 29, 2024

Yeah, you usually don't have optimization flag on while testing/developing. Most languages on Codewars doesn't have optimization/production flag on.

@g964 Why not just provide valid initial solution?

#include <list>

using namespace std;
int last_digit(list<int> array) {
  // Write your code here
  return 0; // <- added
}

This won't prevent users submitting by removing that line, but it should prevent accidental ones.

from codewars-runner-cli.

error256 avatar error256 commented on July 29, 2024

I think a wrapper with noinline may work, like

[[gnu::noinline]]
int last_digit_wrapper(list<int> array) {
  return last_digit(array);
}

It seems that it works even without noinline in this kata, but it's probably less reliable.

from codewars-runner-cli.

kazk avatar kazk commented on July 29, 2024

Amongst the kata I tried some pass and some rightly fail.

Maybe those that fails have dotest wrapper that you often use?

from codewars-runner-cli.

g964 avatar g964 commented on July 29, 2024

I didn't try any others kata of mine except the first I mentioned in my first post.
Examples:

https://www.codewars.com/kata/56c5847f27be2c3db20009c3/train/cpp rightly fails
https://www.codewars.com/kata/576757b1df89ecf5bd00073b/train/cpp "
https://www.codewars.com/kata/56bdd0aec5dc03d7780010a5/train/cpp "

https://www.codewars.com/kata/534d2f5b5371ecf8d2000a08/train/cpp passes
https://www.codewars.com/kata/5886e082a836a691340000c3/train/cpp "
https://www.codewars.com/kata/50654ddff44f800200000004/train/cpp "

from codewars-runner-cli.

kazk avatar kazk commented on July 29, 2024

@error256 Nice find! The kata fails with

main.cpp:9:5: runtime error: execution reached the end of a value-returning function without returning a value

I still think a valid initial solution returning the empty value should be provided though. So add return {};/return 0;/return std::string(); whatever that makes sense.

from codewars-runner-cli.

kazk avatar kazk commented on July 29, 2024

Deployed the fix.

from codewars-runner-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.