Record Case Detail

Notes

This function is in beta test. Please help improve it in the issues here.

Stderr

=================================================================
==50315==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000000010 at pc 0x5574590ed0a9 bp 0x7fff52f02a20 sp 0x7fff52f02a10
READ of size 4 at 0x603000000010 thread T0
    #0 0x5574590ed0a8 in tree_sum_helper /in/ex6.cpp:82
    #1 0x5574590ed108 in tree_sum_helper /in/ex6.cpp:82
    #2 0x5574590ed108 in tree_sum_helper /in/ex6.cpp:82
    #3 0x5574590ed204 in BinaryTree::sum() const /in/ex6.cpp:87
    #4 0x5574590f01ad in test5() /in/compile/TestFunctions.cpp:121
    #5 0x5574590feca2 in std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:316
    #6 0x5574590fe97c in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706
    #7 0x5574590edaa3 in runTests(int) /in/compile/TestFunctions.cpp:19
    #8 0x5574590ebf10 in main /in/compile/test.cpp:13
    #9 0x7f0afb9c3c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
    #10 0x5

Hints

Your answer may be identical to the JOJ answer in the first several lines.

However, the main problem you meet now is Runtime Error. And the exit code of your program is 1, which should be 0.

Please double check your code to solve this problem and try again.

Your Answer


        

JOJ Answer

Test 5: The sum of the tree is 8