[Bug c++/124806] Segfault in elf_out::end() when no mmap support

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124806

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

https://gcc.gnu.org/g:94556938452d2bde01f5954207294906bbb53d8f

commit r17-2849-g94556938452d2bde01f5954207294906bbb53d8f
Author: Torbjörn SVENSSON <[email protected]>
Date:   Sun Jul 26 23:25:50 2026 +0200

    c++: ICE on on systems without mmap support [PR124806]

    On systems without mmap support, cc1plus can crash when finishing module
    output after earlier errors prevented elf_out::begin from running.  In
    that case elf_out::end attempts to fill in the ELF header even though
    hdr.buffer was never initialized.

    gcc/cp/ChangeLog:

            PR c++/124806
            * module.cc (elf_out::began): New data member.
            (elf_out::begin): Set it after successful initialization.
            (elf_out::end): Do not finalize output that never began.

    Signed-off-by: Torbjörn SVENSSON <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.