Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ Bug Took Down Solidity
12 days ago
- #Solidity
- #Compiler
- #C++
- Solc (Solidity compiler) crashes on valid code due to a combination of bugs in G++, Boost, and C++20.
- The issue stems from a 12-year-old G++ bug in overload resolution, favoring non-member functions incorrectly.
- C++20's symmetric comparison feature causes infinite recursion when combined with Boost's outdated comparison pattern.
- Boost versions before 1.75 have a problematic operator== implementation that triggers recursive rewrites in C++20.
- The crash occurs in Solidity when processing compile-time rational comparisons, like T[0].
- Affected environments include G++ < 14, Boost < 1.75, and C++20-enabled builds.
- Recommendations: Update Boost to ≥ 1.75 or use G++ v14+ to avoid the issue.
- This highlights the fragility of build stacks and the importance of testing under multiple compiler and library versions.