On Thu, Nov 06, 2014 at 01:28:28PM +0000, Russell King - ARM Linux wrote:
For the n'th time, what we know is:
- gcc 4.9 bare metal seems to define __SIZE_TYPE__ to be unsigned int.
- gcc 4.9's stddef.h typedef's size_t to __SIZE_TYPE__.
- therefore, size_t is typedef'd from unsigned int.
- the kernel typedefs __kernel_size_t from unsigned int.
- the kernel typedefs size_t from __kernel_size_t.
So, in theory, size_t in the kernel is unsigned int too. However, GCC 4.9 issues loads of complains when %zu or %zd is used with a size_t variable in the kernel.
The question that we've been trying to work out is... why is this? Right now, it seems no one has an answer for this question. We don't know whether it's a compiler bug or not - and Arnd has explained why not.
Isn't this GCC tracking the literal use of size_t in addition to the actual definition and warning based on that information for the size_t specific formatting. Seems weird that it'd only affect a freestanding build though.