1

Is the value returned by sizeof(T*) for every T the same?

Can a sizeof(void*) be a different size than an arbitrary sizeof(T*)?

Raildex
  • 3,406
  • 1
  • 18
  • 42
  • 3
    No, and yes, respectively. There have been machines (none are popular today) where type `char *` was bigger than type `int *`. Under MS-DOS, it was common for data pointers and function pointers to have different sizes. Today, there are variants on 64-bit programming models which use slightly different addressing to not waste bits on full 64-bit addresses everywhere. – Steve Summit Feb 23 '22 at 16:58
  • Pointers to functions is also a problematic area, where pointers to function can be different from other pointers (including different sizes). – Some programmer dude Feb 23 '22 at 17:00
  • 2
    See also [Question 5.17](http://c-faq.com/null/machexamp.html) in the [C FAQ list](http://c-faq.com/). – Steve Summit Feb 23 '22 at 17:01

1 Answers1

0

A common example with select modern architectures is that the size of a void * differs from the size of a pointer to a function.

chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256