https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126839

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hans-Peter Nilsson <[email protected]>:

https://gcc.gnu.org/g:0beb11c5cd142242fba819b09808fd86141a60f8

commit r17-6825-g0beb11c5cd142242fba819b09808fd86141a60f8
Author: Hans-Peter Nilsson <[email protected]>
Date:   Fri Nov 27 06:25:13 2026 +0000

    objc: Correct __objc_class_name_CLASS reference [PR126839]

    r17-2156-g6317befec9, "Objective-C,C++: Rework metadata generation",
    appears to contain two typos, breaking the static linking machinery by
    changing the class-name reference into a dud self-reference, so the
    required classes were not pulled in when linking statically.  To wit,
    this patch corrects from:

            <Class> = &<Class>

    to the apparently intended:

      __objc_class_ref_<Class> = &__objc_class_name_<Class>

    This breakage went unnoticed for dynamic linking where all classes in
    a library are registered at DSO initialization time.

    Trying to use the variable "decl" for both the class name declaration
    and the reference declaration, but instead overwriting it, was part of
    the problem, so I split it into two variables.

    Full disclosure on LLM usage: At the time I entered the PR and glanced
    at the regressed results, I did myself notice the odd change in the
    references, but thought that most of it may have been deliberate.  I
    now had an LLM explain to me what was going on, and point out what was
    wrong with handle_class_ref.  It described the trivial required
    change, which I coded but changed as per the preceding paragraph.  The
    test-case is derived from LLM-generated contents, because I didn't
    know how a trivial objc program looked that performs class lookup, and
    didn't want to copy distracting details from existing tests.  The
    dg-directives match those of some of the existing tests, except this
    is (obviously) the first objc test to specify static linking.

    Assisted-by: LLM

    gcc/objc:
            PR objc/126839
            * objc-gnu-runtime-abi-01.cc (handle_class_ref): Correct class-name
            reference.

    gcc/testsuite:
            * objc.dg/pr126839.m: New test.

Reply via email to