How to determine virtual address length of an x86-64 OS

  aslr, linux, macos, windows, x86-64

Is there a way to determine the virtual address lengths of different variables of a x86-64 operating systems without digging through the documentation of the processor manufacturers or using processor specific assembler code?

Is the virtual address length only determined by the processor independent of the x86-64 operating system?

My approach:

Based on a 64 bit Processors with 4GB RAM each I have observed different pointer lengths:

int *k = (int *) malloc(sizeof(void *));
printf("%p,", k); // observed output length from 9, 11, 12, 16 Hex digits depending on OS and Variable

The problem is these output lengths may be formatted due to different printf() implementations. "%p" can add or remove leading zeros. Furthermore this approach only allows a statement about the word length (64 bit on all OS) and not about the internal virtual address length.

Source: Windows Questions