Skip to content

Comments

C++: Add dmd::printInstantiationTrace to compiler interface#22139

Merged
thewilsonator merged 1 commit intodlang:masterfrom
ibuclaw:cxx_instantiation_trace
Nov 24, 2025
Merged

C++: Add dmd::printInstantiationTrace to compiler interface#22139
thewilsonator merged 1 commit intodlang:masterfrom
ibuclaw:cxx_instantiation_trace

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Nov 24, 2025

Because printInstantiationTrace is an extern(D) method.


So with the following compiler glue code for RTTI.

  if (!global.params.useTypeInfo)
    {
      if (!sc || !sc->ctfe ())
        {
          error_at (loc, "`object.TypeInfo` cannot be used with `-fno-rtti`");

          if (sc && sc->tinst)
            dmd::printInstantiationTrace (sc->tinst);

          global.errors++;
        }
    }

We get stack traces that link back to the originating code along with the error within the druntime template.

core/internal/array/utils.d:154:41: error: ‘object.TypeInfo’ cannot be used with-fno-rtti’
core/internal/array/construction.d:388:24: note: instantiated from here: ‘__arrayAlloc!(Bucket!(int, int))’
core/internal/array/construction.d:402:18: note: instantiated from here: ‘_d_newarrayU!(Bucket!(int, int))’
core/internal/newaa.d:363:16: note: instantiated from here: ‘_d_newarrayT!(Bucket!(int, int))’
core/internal/newaa.d:44:5: note: instantiated from here: ‘Impl!(int, int)’
core/internal/newaa.d:83:25: note: instantiated from here: ‘AA!(int, int)’
core/internal/newaa.d:611:27: note: instantiated from here: ‘_toAA!(int, int)’
testsuite/gdc.dg/rtti1.d:7:16: note: instantiated from here: ‘_d_aaIn!(int[int], int, int, int)’

@ibuclaw ibuclaw added Compiler:GDC Gnu D Compiler Compiler:LDC LLVM based D Compiler Compiler:C++ Interface C++ interface used by LDC/GDC labels Nov 24, 2025
@dlang-bot
Copy link
Contributor

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.

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#22139"

@thewilsonator thewilsonator merged commit 6d6a944 into dlang:master Nov 24, 2025
42 checks passed
@ibuclaw ibuclaw deleted the cxx_instantiation_trace branch November 24, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compiler:C++ Interface C++ interface used by LDC/GDC Compiler:GDC Gnu D Compiler Compiler:LDC LLVM based D Compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants