I’m working with a client who is using an old version of GCC (3.2.3 to be precise) but wants to upgrade and one reason that’s been given as stumbling block to upgrading to a newer version is differences in the size of type float_t which, sure enough is correct:
On GCC 3.2.3
sizeof(float_t) = 12
sizeof(float) = 4
sizeof(double_t) = 12
sizeof(double) = 8
On GCC 4.1.2
sizeof(float_t) = 4
sizeof(float) = 4
sizeof(double_t) = 8
sizeof(double) = 8
but what’s the reason for this difference? Why did the size get smaller and when should and shouldn’t you use float_t or double_t ?
The reason for float_t is that for some processors and compilers using a larger type e.g. long double for float could be more efficient and so the float_t allows the compiler to use the larger type instead of float.
thus in the OPs case using float_t the change in size is what the standard allows for. If the original code wanted to use the smaller float sizes it should be using float.
There is some rationale in open-std doc