Time flies—C++ Insights just turned 7! To celebrate, I’ve upgraded the tool to Clang 20, unlocking even more C++23 and C++26 features for you to explore.
C++ Insights now uses Clang 20
by Andreas Fertig
From the article:
size_t
For a long time now, when you used
size_t
orstd::size_t
the resulting transformation kept the name. It did not expand to the underlying machine-specific date type. To be honest, that was more like a happy accident. Clang 20 came with two changes to libc++The first https://github.com/llvm/llvm-project/commit/d6832a611a7c4ec36f08b1cfe9af850dad32da2e modularized
<cstddef>
for better internal structuring, avoiding too much content to be included. This patch was followed by a second one: https://github.com/llvm/llvm-project/commit/5acc4a3dc0e2145d2bfef47f1543bb291c2b866a. This one now made an interesting change.Previously, libc++ defined
std::size_t
as
1using ::size_t _LIBCPP_USING_IF_EXISTS;
As the second patch highlighted, this required including the operating systems
<stddef.h>
. In the spirit of reducing unnecessary includes the line was changed to:
1using size_t = decltype(sizeof(int));
This is an easy C++ solution to get the proper data type for
size_t
. Which is great. Yet, the AST nodes of the two versions look different. Previously, the operating system (macOS in this case) defined in its header:
1typedef unsigned long size_t;
Well, with the new version, the transformation no longer stops at
size_t
but expands it all down tounsigned long
. This probably should have been the case from the beginning, but I liked that tests and transformations did not change across platforms in this specific case. However, there are other instances where the transformation did yield different output on different platforms, so I accept this one.
Add a Comment
Comments are closed.