{"record":{"id":"74d9363c39c89333","repo":"dotnet/runtime","slug":"demo-array-size-must-be-specified","errorCode":null,"errorMessage":"demo array size must be specified\n","messagePattern":"demo array size must be specified\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/coreclr/gc/vxsort/standalone/demo/demo.cpp","lineNumber":30,"sourceCode":"\nstd::vector<uint8_t*> generate_random_garbage(const uint64_t size) {\n\n    auto vec = std::vector<uint8_t*>(size);\n\n    for (uint64_t i = 0; i < size; ++i) {\n        vec[i] = reinterpret_cast<uint8_t*>(START + (i << SHIFT));\n    }\n\n    std::random_device rd;\n    std::mt19937 g(rd());\n\n    std::shuffle(vec.begin(), vec.end(), g);\n    return vec;\n}\n\nint main(int argc, char** argv) {\n    if (argc != 2) {\n        fprintf(stderr, \"demo array size must be specified\\n\");\n        return -1;\n    }\n\n#if defined(TARGET_AMD64)\n    InitSupportedInstructionSet(1 << (int)InstructionSet::AVX2);\n#elif defined(TARGET_ARM64)\n    InitSupportedInstructionSet(1 << (int)InstructionSet::NEON);\n#endif\n\n    const size_t vector_size = atoi(argv[1]);\n    auto v = generate_random_garbage(vector_size);\n\n    auto begin = v.data();\n    auto end = begin + vector_size - 1;\n\n    uint8_t* range_low =  START;\n    uint8_t* range_high = START + vector_size + 2;\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/gc/vxsort/standalone/demo/demo.cpp#L12-L48","documentation":"The vxsort demo's main (demo.cpp:28-32) requires exactly one command-line argument — the array size. If argc != 2 it prints this and returns -1 before doing any sorting. It is a usage guard for the standalone benchmark, not a runtime algorithm error.","triggerScenarios":"Running `./demo` with no arguments or with more than one argument.","commonSituations":"Invoking the binary without reading its usage; a wrapper script forgetting to pass the size argument.","solutions":["Invoke the demo with exactly one numeric argument, e.g. `./demo 1000000`.","Fix the calling script to pass the array size."],"exampleFix":"// before\n./demo\n// after\n./demo 1000000","handlingStrategy":"validation","validationCode":"// Validate argv before running the sort demo.\nif (argc !== 2) {\n  fprintf(stderr, \"usage: %s <array-size>\\n\", argv[0]);\n  return EXIT_FAILURE;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass exactly one numeric size argument to the demo.","Wrap the demo in a script that asserts the argument."],"tags":["vxsort","demo","cli","usage","argument"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}