Skip to content

Incorrect include suggestion when using header units. #139290

Open
@CubedProgrammer

Description

@CubedProgrammer

Ran into a small issue while building a project of mine.

construct_at and destroy_at are from the memory header.

When the precompiled module is specified on the command line for the memory header, the compiler will see the functions, but will not compile the code since memory is not imported. However, the compiler then suggests to include an implementation-defined header. The correct behaviour should be to suggest to import, not include the standard header it is in, memory in this case.

import<bit>;
struct Q{};
void r()
{
    char unsigned arr[sizeof(Q)];
    Q*p = reinterpret_cast<Q*>(arr);
    std::construct_at<Q>(p);
    std::destroy_at<Q>(p);
}

The command used to compile this is.

clang++ -std=c++20 -stdlib=libc++ -fmodule-file=ccm.cache/bit.pcm -fmodule-file=ccm.cache/memory.pcm -c PROGRAM_FILE

I have not tested if the additional header import is required to reproduce this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions