[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 20 18:59:12 PDT 2017
dexonsmith added a comment.
Hmm... presumably, this test should pass:
$ ./bin/clang -nostdinc -isystem ./lib/clang/5.0.0/include -std=c++1z -fsyntax-only t.cpp
t.cpp:3:1: error: static_assert failed
static_assert(__is_same(intptr_t, __INTPTR_TYPE__));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t.cpp:4:1: error: static_assert failed
static_assert(__is_same(uintptr_t, __UINTPTR_TYPE__));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
$ cat t.cpp
#include <stdint.h>
static_assert(__is_same(intptr_t, __INTPTR_TYPE__));
static_assert(__is_same(uintptr_t, __UINTPTR_TYPE__));
Discovered that it fails (at least for `-triple x86_64-apple-macosx10.12.0`) while writing tests for an improved patch that covers SIZE_MAX, PTRDIFF_MIN/MAX, UINTPTR_MAX, and INTPTR_MAX, since I was trying:
static_assert(__is_same(__typeof__(INTPTR_MIN), intptr_t));
static_assert(__is_same(__typeof__(INTPTR_MAX), intptr_t));
static_assert(__is_same(__typeof__(UINTPTR_MAX), uintptr_t));
static_assert(__is_same(__typeof__(PTRDIFF_MIN), ptrdiff_t));
static_assert(__is_same(__typeof__(PTRDIFF_MAX), ptrdiff_t));
static_assert(__is_same(__typeof__(SIZE_MAX), size_t));
and the first three assertions all failed.
Is `__INTPTR_TYPE__` correct, or is `intptr_t`? Is it safe to fix the one that's wrong?
https://reviews.llvm.org/D31856
More information about the cfe-commits
mailing list