Repository navigation
diagnose comparisons between two arrays (P2865), fix for [GH #370] - #387
mohitmishra786 wants to merge 2 commits into
Conversation
…lowed in C++26. [GH edgcpp#370]
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Diagnostic check and operator integration src/error_msg.txt, src/expr.c |
The built-in equality and relational operator paths check the original operands for two array types. C++20 and C++23 produce deprecation warnings. C++26 produces errors, except when emulating GCC versions before 15 or Clang versions before 20, which produce warnings. |
Standard and compiler-version coverage tests/tests/changes/GH370*.sft.cpp, tests/tests/changes/.GH370*.rto/*, tests/tests/imported/clang/cpp/SemaCXX/*, src/pending_changes/gh-370-array-comparisons.txt |
Tests cover equality and relational comparisons between arrays, array-to-pointer comparisons, and expected diagnostics across language modes and compiler versions. The pending-change note describes the diagnostic conditions. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Merge Risk: 
Minimal · up to 0d4ea
-
The implementation is mergeable; the remaining untested combinations are optional coverage improvements rather than demonstrated failures.
Architecture risk: 
Low · up to 0d4ea
-
The change affects 2 systems.
Changed systems:
tests,srcArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — tests (service) was modified; 18 changed files map to changed impact.
- observed — src (service) was modified; 3 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in src/error_msg.txt: Added diagnostic entries for deprecated and disallowed comparisons between two arrays.
- observed — Modified behavior in src/expr.c: Added
check_for_array_comparison, which checks for two array-typed operands in C++20 mode and diagnoses the comparison. In C++26 mode, it emits an error except on GCC 15+ and Clang 20+, where it emits a deprecation warning. - observed — Modified behavior in src/expr.c: The built-in relational-operator path now checks the original operands for an array comparison before operand transformations.
- observed — Modified behavior in src/expr.c: The built-in equality-operator path now checks the original operands for an array comparison before operand transformations.
-
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#370requires implementing P2865R6, which removes deprecated array comparisons from C++26. The coding requirement is to diagnose comparisons between two arrays using ==, !=, <, <=, >, and >=.Evidence from the whole-PR summary (merge base 35b7c47 to head 0d4eabd):
- src/expr.c adds check_for_array_comparison. It runs in the built-in paths of process_eq_operator and process_rel_operator, before array-to-pointer conversion. When both operands have array type, C++20 and C++23 produce a deprecation warning. C++26 produces an error.
- src/error_msg.txt adds ec_array_comparison_deprecated and ec_array_comparison_not_allowed.
- Test fixtures under tests/tests/changes/.GH370* and GH370*.sft.cpp cover ==, !=, <, and >= between arrays. They expect warnings in C++20, errors in C++26, and no diagnostic for array-to-pointer comparisons.
- Test fixtures show GNU 150000 (GCC 15) and Clang 200000 with C++26 producing errors. Clang 190000 with C++26 produces warnings. This matches the PR description.
The raw summary says C++26 errors apply unless the compiler is GCC 15 or later or Clang 20 or later. That wording conflicts with the PR description and the fixtures, which both place the warning-only exception before GCC 15 and Clang 20. The fixtures support the PR description. This conflict affects only the emulation exception. It does not affect the core C++26 error or C++20 and C++23 warning requirements.
No incremental diff from d5a1e7d was available. This assessment uses the whole-PR summary and the existing test evidence. The core requirement is met.
Full details: Out of Scope Changes check
-
Explanation
All changed files relate to the array-comparison diagnostic for
#370:- src/expr.c: the new check and its call sites in the relational and equality paths.
- src/error_msg.txt: the two new diagnostic messages.
- src/pending_changes/[GNATS 27773] C++26: Remove Deprecated Array Comparisons from C++26 (P2865R6) #370-array-comparisons.txt: the required pending-change note.
- tests/tests/changes/.GH370* and GH370*.sft.cpp: regression fixtures for the new diagnostics.
- tests/tests/imported/clang/cpp/SemaCXX/.deprecated.rto, .self-comparison.rto, .warn-array-comparion.rto, and .warn-self-comparisons.rto: updated expected output. These updates record the new deprecation or error text for existing array-to-array comparisons. They follow directly from the new diagnostics.
No unrelated change is evident in the summary. tests/expectations/edg_x86_64/imported.log is in ignored_files and was not inspected. Its exclusion does not affect this verdict.
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (9 skipped: 9 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
AcknowlEDG review results updated for
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
AcknowlEDG review results updated for
CI success. |
Fixes #370.
A comparison between two arrays with
==,!=,<,<=,>or>=was accepted silently in every mode. It is deprecated in C++20 and not allowed in C++26 (P2865).process_eq_operatorandprocess_rel_operatornow callcheck_for_array_comparisonbefore the array-to-pointer conversion (the same place<=>already rejects two arrays). If both operands have array type:-std=c++26(checked with the gcc:14 and gcc:15 images); Clang implemented P2865 in Clang 20.A comparison between an array and a pointer is not affected.
Summary by CodeRabbit
Bug Fixes