This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Fastest minimum-width integer types and limits macros
Gunther Nikl <gnikl@users.sourceforge.net> writes:
> Ian Lance Taylor wrote:
>> Gunther Nikl <gnikl@users.sourceforge.net> writes:
>>
>>> Here is an example for int_fast8_t:
>>>
>>> typedef signed char int_fast8_t;
>>> #define INT_FAST8_MIN INT8_MIN
>>> #define INT_FAST8_MAX INT8_MAX
>>>
>>> Now if int_fast8_t uses "int" as underlying type like this:
>>>
>>> typedef int int_fast8_t;
>>>
>>> which value is its MIN/MAX macros supposed to have? Is it
>>> allowed to use the same "char" limits as above or do I need
>>> to use
>>>
>>> #define INT_FAST8_MIN INT32_MIN
>>> #define INT_FAST8_MAX INT32_MAX
>>>
>>> in that case?
>>>
>>> So this is not about user code but an implementation question.
>>
>> The value of INT_FAST8_MIN is implementation defined, so you can choose
>> whatever value you like (as long as it is <= -128). That said, the
>> standard seems to suggest that the value should correspond to the value
>> of the underlying type. That is, if int_fast8_t is defined as int, then
>> the value of INT_FAST8_MIN should be INT_MIN. That at least makes
>> INT_FAST8_MIN useful, as otherwise it would always simply have the
>> value -128.
>
> Thanks for the information about the standard. FWIW, I assumed that if
> a fast 8bit type was requested than its only about a 8bit value range
> and thus the 8bit limits are sufficient.
Yes, it's hard to understand why a program would ever want to test
INT_FAST8_MIN. I tried Google CodeSearch but it could only find
definitions, not uses.
Ian