#include <expected>
#include <cmath>

// for printf to not get warnings about std::print throwing...
#include <cstdio>

std::expected<int, int> squareRoot(int value)
{
    if (value < 0)
    {
        return std::unexpected{0};
    } else {
        return std::sqrt(value);
    }
}

// triggers false positive
void sillySquareRootNoReturn(int value)
{
    auto valueResult = squareRoot(value);
    if (not valueResult)
    {
        // NOLINTNEXTLINE(modernize-use-std-print)
        printf("Error: invalid value %d\n", value);
        return;
    }

    auto root = valueResult.value();

    // NOLINTNEXTLINE(modernize-use-std-print)
    printf("the square root of %d is %d\n", value, root);
}

int main() {
    int value = -9;

    sillySquareRootNoReturn(value);

    return 0;
}
