dotnet/runtime · warning

demo array size must be specified

Error message

demo array size must be specified

What it means

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.

Source

Thrown at src/coreclr/gc/vxsort/standalone/demo/demo.cpp:30

std::vector<uint8_t*> generate_random_garbage(const uint64_t size) {

    auto vec = std::vector<uint8_t*>(size);

    for (uint64_t i = 0; i < size; ++i) {
        vec[i] = reinterpret_cast<uint8_t*>(START + (i << SHIFT));
    }

    std::random_device rd;
    std::mt19937 g(rd());

    std::shuffle(vec.begin(), vec.end(), g);
    return vec;
}

int main(int argc, char** argv) {
    if (argc != 2) {
        fprintf(stderr, "demo array size must be specified\n");
        return -1;
    }

#if defined(TARGET_AMD64)
    InitSupportedInstructionSet(1 << (int)InstructionSet::AVX2);
#elif defined(TARGET_ARM64)
    InitSupportedInstructionSet(1 << (int)InstructionSet::NEON);
#endif

    const size_t vector_size = atoi(argv[1]);
    auto v = generate_random_garbage(vector_size);

    auto begin = v.data();
    auto end = begin + vector_size - 1;

    uint8_t* range_low =  START;
    uint8_t* range_high = START + vector_size + 2;

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Invoke the demo with exactly one numeric argument, e.g. `./demo 1000000`.
  2. Fix the calling script to pass the array size.

Example fix

// before
./demo
// after
./demo 1000000
Defensive patterns

Strategy: validation

Validate before calling

// Validate argv before running the sort demo.
if (argc !== 2) {
  fprintf(stderr, "usage: %s <array-size>\n", argv[0]);
  return EXIT_FAILURE;
}

Prevention

When it happens

Trigger: Running `./demo` with no arguments or with more than one argument.

Common situations: Invoking the binary without reading its usage; a wrapper script forgetting to pass the size argument.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/74d9363c39c89333. Report an issue: GitHub.