3 ms·
Does the compiler help? $ cat unsigned.cpp #include <iostream> void f(unsigned int x) { std::cout << "x = " << x << std::endl; } int main() {
by cannam 12y ago
Does the compiler help?
$ cat unsigned.cpp
#include <iostream>
void f(unsigned int x) { std::cout << "x = " << x << std::endl; }
int main()
{
f(-1);
}
$ g++ -Wall -Wextra -Wconversion -Werror unsigned.cpp
$ ./a.out
x = 4294967295
No error, no warning. The two are not really distinct types. See the link I posted above for more argumentation along these lines.