Skip to content

Reject unsafe multilevel pointer qualification conversions [EDGcpfe/28967] - #455

Draft
71iq wants to merge 1 commit into
edgcpp:mainfrom
71iq:fix/edg-28967-deep-pointer-qualification
Draft

71iq wants to merge 1 commit into
edgcpp:mainfrom
71iq:fix/edg-28967-deep-pointer-qualification

Conversation

@71iq

@71iq 71iq commented Nov 1, 2026 •

Copy link
Copy Markdown

In GNU C++ mode, including Clang mode, an implicit pointer conversion that adds const below the first level without adding it at every level in between was accepted with a warning. An example is char ** to const char **. GCC and Clang reject it, and it is not const-safe.

In types.c, the fallback that accepted these conversions no longer applies in GNU C++ mode. One exception remains: when emulating GNU C++ before 8.x or Clang, the qualification conversion check doesn't look through array levels. The new helper qualification_check_skips_arrays keeps the fallback in that case, so a const-safe conversion through an array, such as double *const (*)[3] to const double *const (*)[3], is still accepted.

regressions/edg-28967 covers the rejected two- and three-level conversions, and regressions/edg-28967-positive the valid ones. regressions/edg-28967-array covers conversions through array levels with --clang, --gnu_version=70500 and --gnu_version=130300.

Five imported tests are re-recorded: Clang p6, cwg23xx, cwg3xx and qualification-conversion, and GCC conversion/qual1. Every new error is on a line the source marks as an error.

Tested with the full test suites for edg_x86_64 and edg_x86_64_cp, compared with a run of main, and with the new and changed tests for edg_x86_32 and edg_x86_32_cp.

The Changes entry uses this PR's number until there is an issue for it.

Reported in discussion #297.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The pointer-conversion fallback using same_type_with_added_qualifiers is disabled in GNU C++ mode. Regression tests cover deep pointer qualification assignments, and a changelog entry records the change.

Changes: Pointer qualification conversion

Layer / File(s) Summary
Conversion behavior and regression coverage
src/types.c, tests/tests/regressions/edg-28967.sft.cpp, tests/tests/regressions/edg-28967-positive.sft.cpp, src/pending_changes/edg-28967-deep-pointer-qualification.txt
GNU C++ mode skips the fallback conversion using same_type_with_added_qualifiers; other modes can still use it under the existing conditions. Regression tests cover assignments that add deep const qualifications and accepted qualification assignments. The changelog describes the change.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: bug

Suggested reviewers: nv-cmeerw

Merge Risk: Moderate · up to 1aa33

Existing Clang-mode code using this array conversion may stop compiling. Preserve the Clang-mode behavior before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title names the main change: rejecting unsafe multilevel pointer qualification conversions. The raw summary says GNU C++ mode now rejects deep pointer qualification conversions that add const at a…
Full details: Title check

Explanation

The title names the main change: rejecting unsafe multilevel pointer qualification conversions. The raw summary says GNU C++ mode now rejects deep pointer qualification conversions that add const at a deeper level without the required intermediate levels. The change to src/types.c disables the same_type_with_added_qualifiers fallback in GNU C++ mode, and the added tests cover the rejected and accepted cases. The objectives match this scope.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ee3b38e and 1aa33fa.

Files selected for processing: 4

  • src/pending_changes/edg-28967-deep-pointer-qualification.txt
  • src/types.c
  • tests/tests/regressions/edg-28967-positive.sft.cpp
  • tests/tests/regressions/edg-28967.sft.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

71iq added a commit to 71iq/compiler that referenced this pull request Nov 1, 2026
@edgcpp-bot

Copy link
Copy Markdown
Collaborator

AcknowlEDG review results updated for 1aa33fa2edc6:

@71iq

71iq commented Nov 2, 2026

Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread src/types.c Resolved
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…8967]

In GNU C++ mode (including Clang mode), an implicit pointer conversion
that adds const below the first level without adding it at every
intermediate level (e.g., "char **" to "const char **") was accepted
with a warning.  GCC and Clang reject it.  Make it an error, except where
the qualification conversion check does not look through array levels
in the emulated mode (GNU C++ before 8.x and Clang), so that const-safe
conversions through arrays are still accepted.

Add regression tests, including conversions through array levels in Clang
and GNU C++ 7 modes, and update the recordings of imported tests that
now get the errors their sources expect.
@71iq
71iq force-pushed the fix/edg-28967-deep-pointer-qualification branch from 1aa33fa to e9622d9 Compare November 8, 2026 09:29
@71iq 71iq changed the title Reject unsafe deep pointer qualification conversions Reject unsafe multilevel pointer qualification conversions [EDGcpfe/28967] Nov 8, 2026
@edgcpp-bot

Copy link
Copy Markdown
Collaborator

AcknowlEDG review results updated for e9622d9b5ad4:

CI success.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants