July 9, 2025Jul 9 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 or std::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 1 using ::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: 1 using 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: 1 typedef unsigned long size_t; Well, with the new version, the transformation no longer stops at size_t but expands it all down to unsigned 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.  View the full article
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.