Skip to content

Fix #21619 - ICE core.exception.AssertError@src/dmd/pragmasem.d(456): Assertion failure - #21624

Merged
thewilsonator merged 1 commit into
dlang:stablefrom
ibuclaw:fix_pragma_mangle
Aug 3, 2025
Merged

Fix #21619 - ICE core.exception.AssertError@src/dmd/pragmasem.d(456): Assertion failure#21624
thewilsonator merged 1 commit into
dlang:stablefrom
ibuclaw:fix_pragma_mangle

Conversation

@ibuclaw

@ibuclaw ibuclaw commented Jul 30, 2025

Copy link
Copy Markdown
Member

pragma(mangle) in a declaration and statement context had two diverging semantics, and in some cases differing error messages for the same kind of invalid case.

This change merges the two implementation together into one function so that semantic is consistently applied.

@dlang-bot

Copy link
Copy Markdown

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#21624"

@ibuclaw

ibuclaw commented Jul 30, 2025

Copy link
Copy Markdown
Member Author

Needs loads of tests, as I lost count of so many examples where pragma(mangle) violated the spec.

// second argument ignored - spec says one must be symbol
pragma(mangle, "name", "eman")
struct S {}

// second argument also ignored - spec says there must be one argument only
pragma(mangle, "name", "eman")
S fun() { return S(); }

// accepts call expr with return type aggregate - this is neither a string literal nor type symbol
pragma(mangle, fun(), "name")
class C {}

// likewise, accepts var expression of type aggregate
S var;
pragma(mangle, var, "name")
class D {}

// ignored aggregate declarations wrapped around an attribute declaration
pragma(mangle, "function")
extern(C++) struct _function {}
extern(C++) void cppfun(ref _function);  // mangled as `_function&`, not `function&`.

@ibuclaw
ibuclaw force-pushed the fix_pragma_mangle branch from bc8953e to c276f24 Compare July 30, 2025 18:15
/*
REQUIRED_ARGS: -ignore -v
TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|import|\(imported|semantic|entry|library|function object|function core|\s*$)")
TRANSFORM_OUTPUT: remove_lines("^(predefs|binary|version|config|DFLAG|parse|inline|.*_d_newarrayU|import|\(imported|semantic|entry|library|function object|function core|\s*$)")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This isn't related. Failure was introduced by e33c664.

Comment thread compiler/test/fail_compilation/ice13788.d
Comment thread compiler/test/fail_compilation/issue22682.d Outdated
@ibuclaw
ibuclaw force-pushed the fix_pragma_mangle branch from c276f24 to 3bac874 Compare August 2, 2025 13:43
@ibuclaw
ibuclaw marked this pull request as ready for review August 2, 2025 13:44
@ibuclaw
ibuclaw force-pushed the fix_pragma_mangle branch 4 times, most recently from cfe2df9 to 194a372 Compare August 2, 2025 14:00
Comment thread compiler/test/fail_compilation/issue22682.d
…456): Assertion failure

pragma(mangle) in a declaration and statement context had two diverging
semantics, and in some cases differing error messages for the same kind
of invalid case.

This change merges the two implementation together into one function so
that semantic is consistently applied.
@ibuclaw
ibuclaw force-pushed the fix_pragma_mangle branch from 194a372 to bb7e34b Compare August 2, 2025 14:15
@thewilsonator
thewilsonator merged commit bc6dd9d into dlang:stable Aug 3, 2025
76 checks passed
@ibuclaw
ibuclaw deleted the fix_pragma_mangle branch August 3, 2025 06:24
@dkorpel dkorpel mentioned this pull request Dec 12, 2025
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.

ICE core.exception.AssertError@src/dmd/pragmasem.d(456): Assertion failure

3 participants