llvm / llvm/llvm-project

[Clang] __{,u}INT_FAST{16,32}_TYPE__ is incorrect

Open
#168,333 4 comments 0 reactions 0 assignees View on GitHub
c c++ clang:frontend confirmed
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following should work just fine AFAICT:
```
#include

static_assert(__is_same(int8_t, __INT8_TYPE__));
static_assert(__is_same(int16_t, __INT16_TYPE__));
static_assert(__is_same(int32_t, __INT32_TYPE__));
static_assert(__is_same(int64_t, __INT64_TYPE__));
static_assert(__is_same(int_least8_t, __INT_LEAST8_TYPE__));
static_assert(__is_same(int_least16_t, __INT_LEAST16_TYPE__));
static_assert(__is_same(int_least32_t, __INT_LEAST32_TYPE__));
static_assert(__is_same(int_fast64_t, __INT_FAST64_TYPE__));
static_assert(__is_same(int_fast8_t, __INT_FAST8_TYPE__));
static_assert(__is_same(int_fast16_t, __INT_FAST16_TYPE__));
static_assert(__is_same(int_fast32_t, __INT_FAST32_TYPE__));
static_assert(__is_same(int_fast64_t, __INT_FAST64_TYPE__));
static_assert(__is_same(intptr_t, __INTPTR_TYPE__));
static_assert(__is_same(intmax_t, __INTMAX_TYPE__));

static_assert(__is_same(uint8_t, __UINT8_TYPE__));
static_assert(__is_same(uint16_t, __UINT16_TYPE__));
static_assert(__is_same(uint32_t, __UINT32_TYPE__));
static_assert(__is_same(uint64_t, __UINT64_TYPE__));
static_assert(__is_same(uint_least8_t, __UINT_LEAST8_TYPE__));
static_assert(__is_same(uint_least16_t, __UINT_LEAST16_TYPE__));
static_assert(__is_same(uint_least32_t, __UINT_LEAST32_TYPE__));
static_assert(__is_same(uint_least64_t, __UINT_LEAST64_TYPE__));
static_assert(__is_same(uint_fast8_t, __UINT_FAST8_TYPE__));
static_assert(__is_same(uint_fast16_t, __UINT_FAST16_TYPE__));
static_assert(__is_same(uint_fast32_t, __UINT_FAST32_TYPE__));
static_assert(__is_same(uint_fast64_t, __UINT_FAST64_TYPE__));
static_assert(__is_same(uintptr_t, __UINTPTR_TYPE__));
static_assert(__is_same(uintmax_t, __UINTMAX_TYPE__));
```
However, at least with glibc, a few of the `static_assert`s currently fail. Note that with GCC this does in fact work: https://godbolt.org/z/xjcGzq4Mb

Contributor guide

Open the contributing guide

Research direction

Start by compiling the reproducer from the issue with Clang and glibc, then compare its failing assertions with GCC using the linked Compiler Explorer example. Trace how Clang defines the __INT_FAST and __UINT_FAST type macros and make the listed static_assert checks pass without breaking the other integer type macros.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.