Skip to content

Compiler warning: instruction_funcptr_tracing_table defined but not used with --with-tail-call-interp #158795

Description

@ashm-dev

Bug report

Building CPython with --with-tail-call-interp without Tier 2 / JIT enabled produces a -Wunused-variable compiler warning.

./configure --with-tail-call-interp --with-pydebug
make

Actual behavior

In file included from Python/ceval.c:1113:
Python/opcode_targets.h:1034:29: warning: ‘instruction_funcptr_tracing_table’ defined but not used [-Wunused-variable]
 1034 | static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = {
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expected behavior

Clean build without -Wunused-variable warnings.

Cause

instruction_funcptr_tracing_table is only used when Tier 2 tracing is active (Python/ceval_macros.h references TRACING_DISPATCH_TABLE under #if (_Py_TAIL_CALL_INTERP || USE_COMPUTED_GOTOS) && _Py_TIER2).

When building --with-tail-call-interp without JIT/Tier 2:

  • In computed gotos mode, opcode_tracing_targets_table is already guarded by #if _Py_TIER2 in Tools/cases_generator/target_generator.py.
  • In tail-call mode, instruction_funcptr_tracing_table (both forward declaration and definition) is emitted unconditionally, leaving it unused in Python/ceval.c.

Suggested fix

In Tools/cases_generator/target_generator.py, wrap the forward declaration and definition of instruction_funcptr_tracing_table in #if _Py_TIER2, matching opcode_tracing_targets_table:

# Forward declaration
out.emit("#if _Py_TIER2\n")
out.emit("static py_tail_call_funcptr instruction_funcptr_tracing_table[256];\n")
out.emit("#endif\n")

...

# Table definition
out.emit("#if _Py_TIER2\n")
out.emit("static py_tail_call_funcptr instruction_funcptr_tracing_table[256] = {\n")
for name in sorted(analysis.instructions.keys()):
    out.emit(f"[{name}] = _TAIL_CALL_TRACE_RECORD,\n")
named_values = analysis.opmap.values()
for rest in range(256):
    if rest not in named_values:
        out.emit(f"[{rest}] = _TAIL_CALL_UNKNOWN_OPCODE,\n")
out.emit("};\n")
out.emit("#endif\n")

CPython versions tested on:

CPython main (3.16), 3.15

Operating systems tested on:

Linux

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions