+ 2

crash on solo learn but not on vs

https://www.sololearn.com/en/compiler-playground/c2vXE7bl12PI Above code does not work on solo learn, but works on visual studio. What is the issue?

19th Aug 2024, 7:58 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
9 ответов
+ 4
Ketan Lalcheta Interestingly, your code compiles using cl.exe, but fails using g++. There seems to be some error in the sort method that is ignored by cl compiler but gets caught by g++. cl.exe seems to be less strict with it's compilation. what compiler were you using?
20th Aug 2024, 2:13 AM
Bob_Li
Bob_Li - avatar
+ 8
Ketan Lalcheta By default, VS Code doesn't have a built-in compiler, it uses whatever C++ compiler you have installed on your system like GCC or Clang on Linux/macOS and etc. These compilers handle certain situations differently compared to the compiler used by sololearn
19th Aug 2024, 12:12 PM
Alhaaz
Alhaaz - avatar
+ 4
Ketan Lalcheta I modified your code to work for g++ as well aa cl.exe https://sololearn.com/compiler-playground/cWBv0WeznhPL/?ref=app
20th Aug 2024, 5:13 AM
Bob_Li
Bob_Li - avatar
+ 2
Ketan Lalcheta , the link does not work properly on android devices.
19th Aug 2024, 9:47 AM
Lothar
Lothar - avatar
+ 2
It is having dump core
19th Aug 2024, 10:21 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Thanks @Bob_Li I got the idea of missing return statement on sort function. It would have been great to have the error or warning of same, but that's fine. my code started working with additional line at the end of existing mylist sort() function: return mylist(head); Thanks again..!
20th Aug 2024, 8:27 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Samson Oloyede , please do not post a question inside an already existing post. it would be better if you start your own question, because people may not be aware of your issue.
20th Aug 2024, 3:30 PM
Lothar
Lothar - avatar
+ 1
I am on visual studio 2k17 on windows.so compiler is cl.exe
20th Aug 2024, 4:13 AM
Ketan Lalcheta
Ketan Lalcheta - avatar