GCC Newspaper
JUNE 15, 2026
gcc Proposed

Gccjit dynamic down casting (GCC16 or future GCC17)

Basile Starynkevitch asks about dynamic downcasting capabilities in GCCJIT to determine the type of a `gcc_jit_object` pointer.

Basile Starynkevitch asks about dynamic downcasting capabilities in GCCJIT. Specifically, he wants to determine the underlying type of a gcc_jit_object pointer (e.g., struct, lvalue, field, etc.) at runtime. He needs this functionality for serializing GCCJIT representations to JSON in his RefPerSys software.

In the Thread 2 participants
  1. Basile STARYNKEVITCH <basile@starynkevitch.net> proposer

    Asks about dynamic downcasting capabilities in GCCJIT to identify the type of a `gcc_jit_object` pointer.

    “But is there any dynamic downcasting (or way to dynamically query the GCCJIT "class" of any gcc_jit_object pointer)?”
  2. David Malcolm <dmalcolm@redhat.com> other

    No stance expressed.

Technical Tradeoffs

  • Implementing dynamic downcasting may introduce runtime overhead.
  • Adding type information to `gcc_jit_object` may increase memory usage.
  • The design needs to consider the potential impact on performance and ABI stability.
  • Alternative solutions might involve a different approach to serialization.

In Details

GCCJIT is a library for creating GCC intermediate representation (IR) at runtime. It allows programs to generate and compile code on the fly. This question concerns the ability to determine the type of a gcc_jit_object at runtime, which is needed for serialization purposes. The request is whether one can query the kind of a JIT object.

For Context

GCCJIT is a library that allows programs to generate machine code at runtime. It's useful for implementing features like dynamic languages or just-in-time compilation. This discussion is about how to determine the specific type of an object created with GCCJIT, which is needed for tasks like saving the generated code to a file.

Filed Under: GCCJITJITdowncastingdynamic typingserialization