Skip to content

[clang] __attribute__((__noreturn__)) miscompile #113747

@ZijunZhaoCCK

Description

@ZijunZhaoCCK

__attribute__((__noreturn__)) is miscompiled upstream.
See https://godbolt.org/z/T6nMoa75G from Miguel Young and his comment.

When using the standard [[noreturn]] and _Noreturn in their respective languages, codegen is identical, and correct. The C codegen is obviously wrong and clearly confusing the hell out of LLVM, as evidenced by this instruction sequence:

    jne     .LBB1_1
    mov     rax, qword ptr [rip + baz@GOTPCREL]
    call    rax
.LBB1_1: mov rax, qword ptr [rip + foo@GOTPCREL] call rax

(Just do call foo@PLT?)

My recommendation is that upstream use _Noreturn, or noreturn + <stdnoreturn.h>. Clang is clearly able to get this right, but somehow left hand isn't talking to right hand in the unification algorithm.

(This really isn't a C v. C++ difference at all; both languages define their standard noreturn primitives identically.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categoryobsoleteIssues with old (unsupported) versions of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions