This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __typeof__ (const int)


On 16 February 2017 at 13:29, Aurelien Buhrig wrote:
> Hi,
>
> What does control or what is the rule for the type returned by
> __typeof__ (const int) ?

The type of a const int is ... a const int, of course.

I assume you mean integer constant, not "const int".


> On a private target (using newlib-stdint.h), sizeof(__typeof__ (-32768))
> returns 4 but sizeof(__typeof__ (-32767)) returns 2...

This has nothing to do with __typeof__ only to do with the rules of C
that determine the type of an integer constant,  see
http://en.cppreference.com/w/c/language/integer_constant#The_type_of_the_integer_constant

Presumably your private port has a 16-bit int, so -32768 doesn't fit
in int and has a 32-bit type instead. If that's not the case then you
have a bug in the port and it's selecting the wrong type for the
integer constant -32767.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]