When I run the following program with the latest version of Visual Studio (v17.9.1) with both MSVC or the CLang compiler I get the following output:
Code: Select all
0    0
0    0
0    1.17549e-38
0    2.22507e-308
Code: Select all
#include <cstdint>
#include <limits>
#include <iostream>
using namespace std;
template <typename T> class bug
{
public:
	void run()
	{
		T zero = T(0);
		T min = numeric_limits<T>::max();
		T max = numeric_limits<T>::min();
		if (min > zero) min = zero;
		if (max < zero) max = zero;
		cout << min << "    " << max << endl;
	}
};
int main()
{
	bug<int16_t>b1;
	bug<int32_t>b2;
	bug<float_t>b3;
	bug<double_t>b4;
	b1.run();
	b2.run();
	b3.run();
	b4.run();
	return 0;
}