Skip to content

Fix constexpr constructors in dllimport classes [GH #583] - #584

Open
jakub-labenski wants to merge 1 commit into
edgcpp:mainfrom
jakub-labenski:fix/dllimport-constexpr-defaulted-ctor
Open

jakub-labenski wants to merge 1 commit into
edgcpp:mainfrom
jakub-labenski:fix/dllimport-constexpr-defaulted-ctor

Conversation

@jakub-labenski

@jakub-labenski jakub-labenski commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

default_ctor_can_be_constexpr rejected default constructors of dllimport classes with virtual functions too broadly. It rejected explicitly constexpr defaulted constructors and also suppressed implicit constexpr constructors in GNU and Clang emulation modes.

This change accepts explicitly declared constexpr constructors when they meet the usual requirements. It limits the existing restriction on implicitly generated constructors to Microsoft mode.

Coverage

Adds regression tests for direct and inherited virtual functions, a virtual destructor, and a default member initializer, plus a pending Changes entry.

Verification

  • Both regression tests pass with their recorded output in edg_x86_64 and edg_x86_64_cp.
  • edg-collect-changes --check src/Changes src/pending_changes passes.

Related discussion: #583

Summary by CodeRabbit

  • Bug Fixes
    • Microsoft mode now accepts explicitly constexpr defaulted constructors in dllimport classes with virtual functions when they meet the usual constexpr requirements.
    • GNU and Clang emulation modes no longer let dllimport prevent an implicitly declared default constructor from being constexpr in classes with virtual functions.

@jakub-labenski
jakub-labenski requested a review from a team November 23, 2026 09:49
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The compiler now applies the dllimport virtual-function restriction to implicitly constexpr default constructors only in Microsoft mode. Regression tests cover explicitly and implicitly constexpr constructors, and a pending-change note records the behavior across compiler modes.

Changes: dllimport constexpr constructor handling

Layer / File(s) Summary
Constructor handling and regression coverage
src/class_decl.c, tests/tests/regressions/dllimport-constexpr-defaulted-ctor.sft.cpp, tests/tests/regressions/dllimport-implicit-constexpr-default-ctor.sft.cpp, tests/tests/regressions/.dllimport-constexpr-defaulted-ctor.rto/*, tests/tests/regressions/.dllimport-implicit-constexpr-default-ctor.rto/*, src/pending_changes/gh-583-dllimport-constexpr-defaulted-ctor.txt
The dllimport check now runs only in Microsoft mode and excludes constructors declared constexpr. Regression tests cover explicit and implicit default constructors with direct or inherited virtual functions, plus control cases. Expected outputs and the pending-change note record the tested diagnostics and mode behavior.

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

Change: Bug fix

Suggested labels: bug

Suggested reviewers: daveedvdv, nv-cmeerw, daveedvdv-nvidia

Merge Risk: Minimal · up to d2df4

The change lets explicitly constexpr defaulted constructors in dllimport classes with virtual functions compile, and it keeps the old restriction for implicitly generated constructors in Microsoft mode. Regression tests and a pending-change note are included, and no merge-blocking issue was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Fix constexpr constructors in dllimport classes [GH #583]" names the main change. The objectives say the PR narrows the default_ctor_can_be_constexpr restriction so explicitly constexpr def…
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.
Full details: Title check

Explanation

The title "Fix constexpr constructors in dllimport classes [GH #583]" names the main change. The objectives say the PR narrows the default_ctor_can_be_constexpr restriction so explicitly constexpr defaulted constructors in dllimport classes with virtual functions are accepted, while the implicit-constructor limit applies only in Microsoft mode. The changeset (src/class_decl.c, the pending-change note for GH #583, and the regression tests for dllimport constexpr defaulted and implicit default constructors) matches this. The title is specific and concise, and the issue tag helps scanning.

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 0d4f185 and d2df4b8.

Files selected for processing: 9

  • src/class_decl.c
  • src/pending_changes/gh-583-dllimport-constexpr-defaulted-ctor.txt
  • tests/tests/regressions/.dllimport-constexpr-defaulted-ctor.rto/default.1.1.txt
  • tests/tests/regressions/.dllimport-constexpr-defaulted-ctor.rto/default.2.1.txt
  • tests/tests/regressions/.dllimport-constexpr-defaulted-ctor.rto/default.3.1.txt
  • tests/tests/regressions/.dllimport-implicit-constexpr-default-ctor.rto/default.1.1.txt
  • tests/tests/regressions/.dllimport-implicit-constexpr-default-ctor.rto/default.2.1.txt
  • tests/tests/regressions/dllimport-constexpr-defaulted-ctor.sft.cpp
  • tests/tests/regressions/dllimport-implicit-constexpr-default-ctor.sft.cpp

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

@edgcpp-bot

Copy link
Copy Markdown
Collaborator

AcknowlEDG review results updated for d2df4b85f347:

@edgcpp-bot

Copy link
Copy Markdown
Collaborator

AcknowlEDG review results updated for d2df4b85f347:

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