WEDNESDAY, SEPTEMBER 23, 2026
c++
C++: Improve error recovery for __builtin_is_within_lifetime
Fixes an ICE during error recovery for __builtin_is_within_lifetime when encountering error_mark_node.
This commit resolves an Internal Compiler Error (ICE) that occurred during error recovery for the __builtin_is_within_lifetime intrinsic in C++. The issue arose when error_mark_node appeared unexpectedly within constructors, causing assertions to fail. The fix simplifies error recovery by returning error_mark_node directly in such cases.
In Details
Addresses PR c++/127506 by modifying constexpr.cc's is_within_lifetime to return error_mark_node when encountered, preventing an ICE caused by assertions failing on error_mark_node during error recovery in ctors.
For Context
- __builtin_is_within_lifetime
- A C++ intrinsic function (or builtin) that checks if a given pointer is within the lifetime of a specified object. It's part of memory safety features.
- ICE
- Internal Compiler Error. A situation where the compiler encounters an unrecoverable internal inconsistency and must abort.
- error_mark_node
- An internal GCC representation used during parsing and semantic analysis to mark erroneous code constructs, allowing the compiler to attempt recovery rather than halting immediately.
- constructor
- A special member function in C++ that is automatically called when an object of a class is created. It is used to initialize the object's members.