0
Why do C++ challenges have so many compiler-depending questions which answers are depending on SoloLearn Code compiler?
How to select correct answer on this type of questions if I have almost never been working with SoloLearn codeplayground? I'm working with GCC C++ compilers and MSVC compilers for 2 years and I've never seen that you can allocate memory on 0 lenght int[] array or you can delete data by nullptr pointer(you get error: double free or corruption). So I think that challenge questions shouldn't include compiler-depending questions.
4 ответов
+ 6
According to C++ standard declaring of array of zero size is not allowed.
But it is allowed to allocate array of zero size with new operator. The resulting pointer must not be dereferenced (dereferencing will be compiler dependent behaviour).
delete of nullptr is also allowed, but call of the deallocation function is compiler dependent.
----
I agreed. C++ challenges have compiler-depending questions.
Moreover, there are couple of challenges with wrong answers (like "Struct can have classes inside of it" -> false, but correct answer is true).
I marked these questions as wrong couple of monthes ago, but they are still not fixed.
0
I'm sure there are some compiler depended questions out there, but allocating a dynamic array with 0 elements and attempting to delete a nullptr ( it's a no op ) is completely valid C++.
0
I'm sure that in Microsoft Visual Studio you'll get an error by creating int[0] array. But question is still actual.
0
Yes challenges shouldn't include, questions that are compiler dependent, may be they got upvoted and got approved in process
// I never had that kind of luck though :)
If you see any please report those to:
info@sololearn.com
For removal