On June 8, 2026, developer clonker from the core Solidity team identified a significant medium-severity bug lurking within the analysis phase of the Solidity compiler. The flaw is triggered when the compiler emits Warning 3495, an alert designed to warn developers when a custom storage layout is situated perilously close to the upper limit of the Ethereum Virtual Machine’s storage space. While the warning mechanism serves an essential protective role in smart contract design, its underlying implementation contained a critical oversight: it inadvertently reversed the C3-linearized list of base contracts for the contract undergoing validation. Because this precise inheritance linearization drives vital architectural decisions across the entire compiler framework, the accidental reversal opens the door to severe miscompilations and unexpected internal compiler errors.
The vulnerability resides squarely within the language frontend’s analysis phase. Consequently, it operates independently of the chosen compilation pipeline, meaning that both the IR (Intermediate Representation) and traditional evmasm code generation pipelines are equally susceptible. Pure Yul codebases remain entirely unaffected by the flaw. Furthermore, transient storage is untouched, primarily because custom storage layouts are structurally implemented exclusively for persistent storage variables.
Tracing the origin of the bug reveals that it was inadvertently introduced in Solidity version 0.8.29—the exact release that introduced the storage-end warning feature. Every subsequent release ranging from version 0.8.29 through 0.8.35 carries the defect. Fortunately, the Solidity team acted swiftly upon discovery, successfully patching the vulnerability in Solidity version 0.8.36.
To gauge the real-world exposure of this flaw, security researchers conducted extensive preliminary screenings. A comprehensive GitHub search looking for Foundry configuration files explicitly suppressing Warning 3495 returned zero results, strongly indicating that intentionally situating storage variables at excessively high memory addresses is an exceedingly rare practice among developers. This finding was further corroborated by a targeted Sourcify scan across verified smart contracts, which similarly failed to uncover any deployed contracts matching the vulnerable pattern.
Which Contracts Are Affected?
A smart contract is considered vulnerable and potentially affected by this compiler flaw only if a specific combination of conditions occurs simultaneously during the build process. Most importantly, the contract must utilize both an advanced inheritance hierarchy and a custom storage layout located near the extreme end of the storage space.
Because custom storage layouts placed near the absolute end of storage are already exceptionally uncommon—and because the compiler actively discourages this practice by throwing a prominent warning—the precise pattern required to trigger the bug is rarely seen in production environments. Developers should take immediate comfort in the fact that if a contract does not utilize a custom storage layout combined with multi-contract inheritance, it is completely immune to this issue.
Technical Details
A deeper examination of the compiler internals reveals the exact mechanical root cause of the flaw. The storage-end warning feature was originally shipped in Solidity 0.8.29 to protect developers from painting themselves into a corner regarding future contract upgradability. Solidity permits developers to place storage variables at a custom base slot utilizing a layout at clause. When the static portion of that layout approaches the upper boundary of the theoretical $2^256$ available storage slots, the compiler issues a warning. This alert signals that future upgrades might cause the layout to exceed the remaining slot capacity, a condition that would otherwise be rejected by the compiler. Specifically, the warning triggers when the number of free slots remaining after the layout falls below $2^64$.
Triggering this condition accidentally via a hash-based layout expression—such as the widely used erc7201() pattern—possesses a vanishingly small probability, roughly comparable to a mapping element randomly landing on a specific pre-designated slot.
The core implementation failure, however, lies within the inheritance-order reversal bug itself. The routine responsible for generating the storage-end warning needs to inspect base contracts to identify which variable sits closest to the storage boundary. To accomplish this, the code walks the list stored in the linearizedBaseContracts Abstract Syntax Tree (AST) annotation in reverse order. Rather than operating safely on a copied sequence, the helper function unwittingly performed the reversal in-place, permanently mutating the underlying data structure accessed by the rest of the compiler.
In implementation terms, this catastrophic mutation stemmed from using the actions::reverse helper from the popular ranges-v3 C++ library instead of the intended views::reverse utility. While views::reverse produces a non-destructive, reversed view of a container, the actions variant aggressively mutates the underlying container itself. Compounding the issue, both helpers share virtually identical signatures, allowing the subtle error to bypass initial code reviews.
The helper function in question is exclusively invoked when the storage-end warning is emitted. Consequently, data corruption is strictly isolated to contracts that trigger this specific warning. A secondary contributing factor was the architectural design of the compiler’s annotation system, where annotations are traditionally treated as mutable. This design choice violates strict const-correctness principles, preventing the C++ compiler from flagging the destructive actions::reverse call as an invalid operation.
Once the linearizedBaseContracts annotation is corrupted, the C3 linearization encoding the inheritance hierarchy is inverted. Because subsequent phases of analysis and code generation rely heavily on this order to resolve object references, any resolution dependent on inheritance sequence produces erroneous results. Confirmed cascading effects include a reversed state-variable initialization order, inverted constructor invocation sequences, misrouted super and virtual-function resolutions, incorrect virtual modifier evaluation, and flawed resolution of virtual fallback and receive functions. Furthermore, this inverted order is visibly exported directly into AST JSON outputs. Depending on the complexity of the contract, these failures manifest either as silent miscompilations or as glaring internal compiler errors.
Example
To illustrate how the bug manifests in practice, consider a minimal, highly specific smart contract structure designed to meet the necessary vulnerability conditions:
contract A
uint public x;
constructor()
x = 1;
contract B is A
constructor()
x = x * 10;
contract C is A, B layout at 2**256 - 2**40
constructor()
x = x + 5;
In this architecture, the intended inheritance hierarchy flows from A to B to C, with constructors executing sequentially from left to right. Deploying contract C under normal conditions should initialize x to 1, multiply it by 10 in contract B, and add 5 in contract C, yielding a final stored value of 15. However, the inclusion of the layout at 2**256 - 2**40 clause pushes the storage layout into the final $2^64$ slots, successfully triggering the storage-end warning and instigating the disastrous list reversal.
Under the influence of the bug, deploying contract C results in x evaluating to 5. Because the linearization list has been inverted, the constructors run in an entirely incorrect sequence. Removing the layout clause—and thereby avoiding Warning 3495—causes the exact same code to compile correctly, yielding the expected value of 15.
Severity Assessment
The Solidity team has categorized this vulnerability as having a medium severity rating. If successfully triggered, the potential impact on an individual contract is high, capable of silently scrambling critical inheritance-dependent behaviors such as state-variable initialization and constructor execution flows.
Nevertheless, the real-world probability of encountering this bug is exceptionally low. The flaw requires the simultaneous presence of complex multi-contract inheritance and a custom storage layout intentionally positioned within the final $2^64$ slots of the EVM storage space. Given that there are no standard development patterns requiring storage positioning at such astronomical addresses, and automated scans of public source repositories confirmed an absolute absence of affected production code, the risk profile remains minimal. Furthermore, contracts that do not utilize inheritance are entirely immune.
It is also worth noting that the bug does not always result in a silent, insidious miscompilation. In non-trivial contract hierarchies involving advanced features like super calls, explicit constructor parameters, or cross-variable dependencies, the inverted inheritance tree frequently triggers an internal compiler error or generates invalid intermediate representation. This causes the build to fail explicitly at compile time rather than permitting flawed code to be pushed to a live blockchain network.
The Fix
The permanent resolution implemented by the Solidity team is precise and targeted. Developers of the compiler have replaced the erroneous ranges::actions::reverse call with the safe ranges::views::reverse utility within the frontend analysis logic. This adjustment ensures that the compiler iterates over a temporary, reversed view of the base contract list during warning evaluation without mutating the foundational AST annotations relied upon by subsequent compilation phases.
Recommended Actions
Developers who maintain smart contracts utilizing complex inheritance structures are advised to review their toolchains. Anyone utilizing Solidity versions ranging from 0.8.29 through 0.8.35 should upgrade their compiler toolchains to Solidity version 0.8.36 or later. Projects employing custom storage layouts should verify that their layout expressions do not inadvertently drift into the final $2^64$ slots of EVM storage, thereby avoiding Warning 3495 entirely and ensuring absolute determinism across all compilation passes.
Acknowledgements
The Solidity core development team discovered, diagnosed, and remediated this internal compiler vulnerability entirely through internal code reviews and testing protocols.

