Skip to content

Clang 19.1.7 crash during lambda compilation with naked attribute #133143

Open
@alpluspluss

Description

@alpluspluss

Version: 19.1.7
Host OS: macOS Sonoma 14.4
Flags: -ffreestanding -mcmodel=kernel
Target: x86_64-none-elf

Code:

/* syscall entry point */
static auto syscall_entry = []() __attribute__((naked))
{
    asm volatile(
        "swapgs\n"
        "movq %rsp, %gs:16\n"
        "movq %gs:8, %rsp\n"
        "ret"
    );
};

I happened to run into a crash when compiling kernel code using a lambda with __attribute__((naked)).
This code doesn't crash during compilation with x86_64-elf-g++. I may be able to contribute a fix for this issue if needed.

Link to the attached file as I am not able to attach it normally: https://pastebin.com/GzeB8ga7

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]lambdaC++11 lambda expressions

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions