Is it time to take middle-end stringop/array warnings out of -Wall?
Richard suggests that middle-end diagnostics should enable diagnostic-paths to show currently visible preconditions in C++.
Richard Biener comments on a previous proposal to categorize certain warnings as -Wmiddle-end. He suggests diagnostics should enable diagnostic-paths, to show currently visible preconditions. Biener notes that in C++ the set of visible preconditions depends heavily on inlining decisions, which affects how useful these warnings are.
- proposer
Suggests that diagnostics should enable diagnostic-paths, especially in C++, to show currently visible preconditions and improve the usefulness of middle-end warnings.
“Much like that diagnostics that do this should probably enable diagnostic-paths, at least for their emitted diagnostics. Because the path is what shows the currently visible preconditions. Remember that esp. with C++ the set of visible preconditions is heavily dependent on inlining decisions.”
- other
Acknowledges Richard's reply.
- other
Acknowledges Richard's reply.
Technical Tradeoffs
- Enabling diagnostic-paths may increase compilation time.
- May require changes to GCC's internal data structures to efficiently track and display preconditions.
In Details
GCC's middle-end performs optimizations and transformations on the intermediate representation (IR) of code. Stringop/array warnings detect potential buffer overflows or out-of-bounds accesses during this phase. Diagnostic paths trace the flow of data and control in the IR, revealing preconditions that influence optimization and warning behavior.
For Context
Compilers use a multi-stage process to translate human-readable code into machine instructions. After parsing and initial conversion, the "middle-end" stage optimizes the code. This stage can detect potential errors, such as writing beyond the boundaries of an array. These errors may depend on conditions checked earlier in the code; diagnostic paths can help developers understand how those conditions affect the warning.