Skip to content

Fix Issue 23650 - Using typeid with struct defined in __traits(compiles, ...) causes linker error#14844

Merged
RazvanN7 merged 1 commit intodlang:masterfrom
RazvanN7:Issue_23650
Jan 26, 2023
Merged

Fix Issue 23650 - Using typeid with struct defined in __traits(compiles, ...) causes linker error#14844
RazvanN7 merged 1 commit intodlang:masterfrom
RazvanN7:Issue_23650

Conversation

@RazvanN7
Copy link
Contributor

@RazvanN7 RazvanN7 commented Jan 24, 2023

Currently blocking: #14664

If a typeid is encountered in a speculative context it should not generate any Typeinfo.
The actual typeinfo ast node is generated so that assignments such as Typeinfo a = typeid(b)
still work.

@RazvanN7 RazvanN7 added the Review:Blocking Other Work review and pulling should be a priority label Jan 24, 2023
@RazvanN7 RazvanN7 requested a review from ibuclaw as a code owner January 24, 2023 13:14
@dlang-bot
Copy link
Contributor

dlang-bot commented Jan 24, 2023

Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
23650 blocker Using typeid with struct defined in in __traits(compiles, ...) causes linker error

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

To target stable perform these two steps:

  1. Rebase your branch to upstream/stable:
git rebase --onto upstream/stable upstream/master
  1. Change the base branch of your PR to stable

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 "master + dmd#14844"

@RazvanN7 RazvanN7 changed the title Fix Issue 23650 - Using typeid with struct defined in in __traits(compiles, ...) causes linker error Fix Issue 23650 - Using typeid with struct defined in __traits(compiles, ...) causes linker error Jan 24, 2023
@RazvanN7
Copy link
Contributor Author

cc @teodutu

@RazvanN7 RazvanN7 force-pushed the Issue_23650 branch 3 times, most recently from 68310f1 to f592ee3 Compare January 25, 2023 10:33
sc2.flags = sc.flags & ~SCOPE.contract;
if (sc2.flags & SCOPE.compile)
funcdecl.skipCodegen = true;
sc2.flags &= ~SCOPE.compile;
Copy link
Contributor Author

@RazvanN7 RazvanN7 Jan 25, 2023

Choose a reason for hiding this comment

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

Currently dmd has multiple ways of checking for speculative context, each with its subtle differences:

  • sc.minst and sc.tinst are both null.
  • sc.flags & SCOPE.compile
  • FuncDeclaration.skipCodegen
  • FuncDeclaration.isCompileTimeOnly

Here, SCOPE.compile is randomly cleared because it is used for attribute inference in a different place.
The entire situation is crazy...

I'm looking into simplifying the mess, but until that point, I'm using skipCodegen to signal typeid that we are in a speculative context. I tried all of the above, but only skipCodegen works.

@RazvanN7 RazvanN7 merged commit 48c3e38 into dlang:master Jan 26, 2023
kinke added a commit to kinke/dmd that referenced this pull request Nov 27, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to kinke/dmd that referenced this pull request Nov 27, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to kinke/dmd that referenced this pull request Nov 27, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to kinke/dmd that referenced this pull request Nov 27, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to symmetryinvestments/dmd that referenced this pull request Nov 28, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to symmetryinvestments/dmd that referenced this pull request Nov 28, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to symmetryinvestments/dmd that referenced this pull request Dec 6, 2023
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to symmetryinvestments/dmd that referenced this pull request Feb 1, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to symmetryinvestments/dmd that referenced this pull request Mar 26, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to symmetryinvestments/dmd that referenced this pull request May 30, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion).
kinke added a commit to kinke/dmd that referenced this pull request Jun 11, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
kinke added a commit to kinke/dmd that referenced this pull request Jul 2, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
kinke added a commit to kinke/dmd that referenced this pull request Jul 2, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
kinke added a commit that referenced this pull request Jul 2, 2024
Reverting #14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request Oct 7, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request Oct 7, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request Oct 7, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request Oct 7, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request Oct 7, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
RazvanN7 added a commit that referenced this pull request Oct 7, 2024
* Document template instance duplication status as part of its field documentation. (#16643)

* Fix Bugzilla 24599 - Wrongly elided TypeInfo emission (#15868)

Reverting #14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).

* Reorganize backend build files to match target and make more similar per line (#16672)

* Remove redundant suggestions on linker errors (#16711)

* Fix bugzilla 24337 - Segfault when printing an int[] cast from a string (#16729)

* Add BitFieldStyle.Gcc_Clang_ARM

Required for 32-bit ARM, and non-Apple 64-bit ARM targets.

The only difference to `Gcc_Clang` is that anonymous and 0-length
bit-fields do contribute to the aggregate alignment.

Caught by existing proper C interop tests in
runnable_cxx/testbitfields.d on such targets. The hardcoded bad tests
in runnable/{bitfieldsposix64.c,dbitfieldsposix64.d} however now fail
after the fix, on such targets again.

* [refactor to `TargetC.contributesToAggregateAlignment(BitFieldDeclaration)` hook]

* Fix Bugzilla Issue 24687 - [REG2.110] Cannot cast string-imports to select overload anymore

* Also make deprecationSupplemental adhere to error limit (#16779)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24699 - [REG2.108] No short-circuit evaluation of mixing template bool argument

* Fix bugzilla 24731 - IFTI cannot handle integer expressions (#16822)

* Fix Bugzilla Issue 24760 - ICE on variadic after default argument

* Fix bugzilla 24790 - -vcg-ast ICE on lowered assign exp (#16914)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24764 - ICE when -vcg-ast prints imported invariant (#16917)

Co-authored-by: Dennis Korpel <dennis@sarc.nl>

* Fix bugzilla 24431 - dmd -vcg-ast crashes printing failed template in… (#16916)

---------

Co-authored-by: Richard (Rikki) Andrew Cattermole <richard@cattermole.co.nz>
Co-authored-by: Martin Kinkelin <kinke@users.noreply.github.com>
Co-authored-by: Dennis <dkorpel@users.noreply.github.com>
Co-authored-by: Martin Kinkelin <mkinkelin@symmetryinvestments.com>
Co-authored-by: Martin Kinkelin <noone@nowhere.com>
Co-authored-by: RazvanN7 <razvan.nitu1305@gmail.com>
Co-authored-by: Dennis Korpel <dennis@sarc.nl>
Co-authored-by: Dennis Korpel <dkorpel@gmail.com>
royalpinto007 pushed a commit to royalpinto007/dmd that referenced this pull request Oct 11, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
royalpinto007 pushed a commit to royalpinto007/dmd that referenced this pull request Nov 15, 2024
Reverting dlang#14844, which caused such missing TypeInfos, *and* making
sure the special TypeInfo members are fully analyzed and ready for
codegen (otherwise hitting an assertion for the real-world project).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:Blocking Other Work review and pulling should be a priority Severity:Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants