Obscure feature and obscure feature and obscure feature = compiler bug
3 days ago
- #Software Testing
- #Compiler Bugs
- #C++
- The article discusses how combining obscure features in C++ can lead to compiler bugs, illustrated by a real-world example involving the clang++ compiler.
- Antithesis SDKs are introduced, which allow developers to add assertions to their code for correctness properties, with examples like ALWAYS, REACHABLE, and SOMETIMES.
- The implementation of these assertions involves emitting JSON messages to Antithesis for evaluation, including a catalog of all assertions at startup.
- A solution using C++ static initialization and non-type template parameters is detailed to emit the catalog without external tools.
- The article highlights a bug in clang++ related to symbol deduplication when using the same message in different files, exacerbated by anonymous namespaces and non-type template parameters.
- The broader lesson is about the complexity of bugs arising from combinations of rare features or conditions, and how autonomous testing can help uncover them.