This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: wrong decltype( INTN_C(value) )?
- From: Yaron Cohen-Tal <yaronct at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Mon, 28 Mar 2016 16:37:38 +0300
- Subject: Re: wrong decltype( INTN_C(value) )?
- Authentication-results: sourceware.org; auth=none
- References: <CADKOXrCAiBemEY90LNot3HAfrjFj97V2hv_3Mz6JZgzdec28jA at mail dot gmail dot com> <56F923DD dot 5000403 at linaro dot org>
Where is this quote from? I couldn't find it in the C99 standard.
On Mon, Mar 28, 2016 at 3:30 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
> On 27-03-2016 17:54, Yaron Cohen-Tal wrote:
>> Hi,
>>
>> I was wondering: according to the C99 standard (I couldn't get hold of
>> the C11 standard) it seems like e.g. "INT8_C" should have the type
>> "int_least8_t". From section 7.18.4.1:
>>
>> "The macro INTN_C(value) shall expand to a signed integer constant
>> with the specified value and type int_leastN_t"
>>
>> However, on my system (Debian 8 x64) "INT8_C(1)" expands to "1" which
>> has type "int" (which is 32 bit) whereas "int_least8_t" has type
>> "signed char" (which is 8 bit). So is glibc not conformant to the
>> standard here, or there's anything I misunderstand? I'd expact it to
>> expand to "((signed char)1)".
>>
>
> My understanding is it falls to:
>
> 7.18.4 Macros for integer constants
>
> 3. Each invocation of one of these macros shall expand to an integer
> constant expression suitable for use in #if preprocessing directives.
> The type of the expression shall have the same type as would an
> expression of the corresponding type *converted according to the
> integer promotions*. The value of the expression shall be that of
> the argument.
>
> Since it it should use default C99 integer promotions the macro should
> not promote to smaller than int types.