Skip to content

C: diagnose pointer conversions that add qualifiers below the first level [] - #498

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

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

Conversation

@71iq

@71iq 71iq commented Nov 8, 2026

Copy link
Copy Markdown

In C, the front end accepted an implicit conversion that adds qualifiers below the first level, such as int ** to const int *const *, without a diagnostic. C++ allows this conversion. In C the pointed-to types are not compatible, so it violates the constraints of simple assignment (C23 6.5.17.2), and a diagnostic is required. GCC 14 and later reject it by default.

In types.c, a C conversion that takes this path now gets the caller's default warning when no more specific warning applies. The conversion is still accepted.

regressions/c-deep-pointer-qualification checks for the warning in GNU C23 mode and with --strict_warnings. regressions/c-deep-pointer-qualification-positive checks that adding const only at the first level, or converting with an explicit cast, gets no diagnostic in strict mode, and regressions/cpp-deep-pointer-qualification that C++ is unchanged.

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 refers to the discussion until there is an issue for it.

Reported in discussion #472.

…evel []

In C, an implicit conversion such as "int **" to "const int *const *" is
valid in C++ but violates the constraints of simple assignment, because
the types pointed to are not compatible (C23 6.5.17.2), so a diagnostic
is required (C23 5.1.1.3).  The front end accepted it as an extension
without one.  Issue the caller's default warning when no more specific
warning applies; the conversion is still accepted.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

@edgcpp-bot

Copy link
Copy Markdown
Collaborator

AcknowlEDG review results updated for 3deca25d2018:

@edgcpp-bot

Copy link
Copy Markdown
Collaborator

AcknowlEDG review results updated for 3deca25d2018:

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