Always include the proper header as specified in your reference (such as cppreference.com). The proper header is, and as far as I know has always been, <algorithm>. Always compile using a specific standard and high warning level. These days you should be using C++11 at a bare minimum, better still C++14, and preferably C++17.
I think you are just assuming that min() was in <cmath>. It could've been defined inside <iostream>. For example, with g++ -std=c++11 -Wall -W -pedantic this compiles without warnings:
Code:
#include <iostream>
int main() {
int a = 1, b = 2;
std::cout << std::min(a, b) << '\n';
std::cout << std::max(a, b) << '\n';
}
<iostream> is defined in the standard to include <ios> (which includes <iosfwd>), <streambuf>, <istream>, and <ostream>, as well as defining i/o objects like cout and cin. Apparently at least one of those headers in the g++ implementation that I used either includes <algorithm> (which seems unlikely) or simply defines min() and max() for its own use (presumably inline so there's no issue with multiple definitions).
But you cannot rely on that and should therefore always include the proper header.