16 Nov 2026, Mon

Solidity Team Discovers and Patches Medium-Severity Compiler Bug Affecting Inheritance and Storage Layouts

On June 8, 2026, developer clonker from the core Solidity team identified a significant bug residing within the analysis phase of the Solidity compiler. The vulnerability, which has been assigned a medium severity rating on the team’s internal scale, manifests when the compiler evaluates custom storage layouts and subsequently issues Warning 3495. This specific warning alerts developers when a custom storage layout is situated dangerously close to the upper limit of the total available storage space.

While the warning itself serves as a vital safeguard for contract upgradability, the internal mechanism designed to implement it introduced an unintended side effect. Specifically, the warning’s implementation reverses the C3-linearized list of base contracts for the contract currently undergoing checks. Because this critical linearization order governs inheritance-dependent decisions throughout the compiler’s entire pipeline, the unexpected reversal can trigger serious miscompilations as well as internal compiler errors.

The bug is situated squarely within the language frontend’s analysis phase. Consequently, it operates independently of the chosen compilation pipeline, meaning that both the intermediate representation (IR) and legacy evmasm pipelines are affected. On a brighter note, pure Yul code remains entirely unaffected by the flaw. Furthermore, transient storage is untouched because custom storage layouts are exclusively implemented for persistent storage within the Ethereum Virtual Machine ecosystem.

Affected Versions and Discovery

Historical code analysis revealed that the bug was originally introduced in Solidity 0.8.29, the exact release that first incorporated the storage-end warning feature. Because the faulty helper function remained completely unchanged from its inception, every subsequent version spanning from Solidity 0.8.29 through 0.8.35 is impacted. Fortunately, the Solidity team acted swiftly upon discovery, fully resolving the issue in Solidity 0.8.36.

To gauge the real-world impact of the bug, the team conducted preliminary audits across public repositories. A targeted GitHub search seeking out Foundry configurations that deliberately suppress Warning 3495 yielded zero results. This absence strongly suggests that intentionally positioning storage variables at excessively high memory addresses is an exceedingly rare practice among developers. This finding was further corroborated by a comprehensive Sourcify scan for affected contracts, which similarly returned no matching instances in the wild.

Which Contracts Are Affected?

A smart contract is considered vulnerable and potentially affected only if a specific combination of conditions occurs simultaneously during the compilation process. Specifically, the contract must utilize a custom storage layout via the layout at clause, that layout must be placed extremely close to the end of the total available storage space, and the contract must involve a complex inheritance hierarchy.

Because custom storage layouts situated near the very end of storage are already uncommon, and because the compiler actively warns developers against doing so, the exact pattern required to trigger the bug is exceptionally rare in practical development environments. Developers can rest assured that if their contracts do not make use of custom storage layouts combined with multi-contract inheritance, they are entirely unaffected by the vulnerability regardless of the compiler version used.

Technical Details and Root Cause

For developers and security researchers interested in the low-level implementation mechanics, the root cause of the vulnerability traces back to the manipulation of the linearizedBaseContracts AST annotation. During compilation, the code

responsible for emitting Warning 3495 needs to traverse the inheritance list in reverse order to precisely identify which state variable sits closest to the storage boundary.

Instead of creating a safe, isolated copy of the list for this traversal, the warning logic inadvertently performed the reversal directly in-place. This mutated the underlying data structure permanently, altering the reference values for the remainder of the compilation pipeline. Implementation-wise, this stemmed from the accidental deployment of the actions::reverse helper function from the widely used ranges-v3 library, when the developers actually intended to invoke views::reverse.

While views::reverse produces a non-destructive reversed view of a container, the actions variant explicitly mutates the underlying container itself. Compounding the issue, both helper functions share identical signatures, allowing the erroneous call to bypass detection during code review. The helper function is invoked exclusively when the warning is triggered, ensuring that memory corruption only takes place within contracts that meet the warning criteria. Additionally, the underlying design of the Solidity compiler’s annotation system permits mutable annotations to bypass strict const-correctness principles, preventing the C++ compiler from flagging the mutating action as invalid.

Effect on the Rest of the Compiler

The linearizedBaseContracts annotation encodes the vital C3 linearization of an inheritance hierarchy, a structure that is consulted repeatedly throughout both analysis and code generation phases. When this list is inadvertently reversed, any resolution process relying upon inheritance order is bound to produce erroneous outcomes.

Confirmed downstream effects of this state corruption include a completely reversed state-variable initialization sequence, incorrect constructor invocation orders, and flawed resolution of super and virtual functions. Furthermore, the bug compromises virtual modifier resolution as well as virtual fallback and receive function resolution. In some cases, these reversals manifest as silent miscompilations where bytecode is generated incorrectly without throwing explicit errors. In other scenarios, the anomalies surface loudly as internal compiler errors or invalid IR during the build process.

A Minimal Reproducer Example

To demonstrate how the vulnerability manifests in actual code, the Solidity team provided a minimal reproducer contract that satisfies all necessary trigger conditions. Consider three simple contracts where contract A defines a public uint variable x initialized to 1 within its constructor, contract B inherits from A and multiplies x by 10, and contract C inherits from B while introducing a layout at 2256 – 240 clause.

Ordinarily, the inheritance hierarchy flows linearly from A through B to C, meaning constructor logic executes sequentially from left to right. Deploying contract C under normal circumstances should result in x evaluating to fifteen, calculated as one multiplied by ten plus five. However, the presence of the layout at clause places the storage layout within the final two to the power of sixty-four slots, triggering the storage-end warning and activating the inheritance order reversal.

Under the influence of the bug, deploying contract C yields an unexpected value of five for x because the corrupted linearization executes constructors in the reverse order. Removing the layout clause eliminates the warning entirely, allowing the exact same contract code to compile correctly and yield the expected value of fifteen.

Severity Assessment and Recommended Actions

Although the theoretical impact of the bug is high—capable of silently miscompiling inheritance-dependent logic like constructor execution and variable initialization—the practical likelihood of encountering it remains exceptionally low. The defect exclusively triggers under conditions that the compiler already actively discourages via Warning 3495. Furthermore, automated scans on Sourcify confirmed that no deployed contracts are currently utilizing the vulnerable pattern in production.

Moreover, the corruption does not always result in a silent failure. In non-linear hierarchies involving advanced features such as explicit super calls, constructor parameters, or intricate storage dependencies, the reversed ordering is highly likely to trigger an internal compiler error or generate invalid IR. This ensures that developers are alerted to the problem at compile time rather than deploying flawed code to the blockchain.

The Solidity team has released version 0.8.36 to permanently resolve the issue by replacing the mutating ranges::actions::reverse helper with the safe ranges::views::reverse implementation. Developers currently utilizing versions 0.8.29 through 0.8.35 are strongly encouraged to upgrade their compiler toolchains to version 0.8.36 to ensure complete safety and maintain robust compilation standards.