Skip to content

_Complex _BitInt is inconsistently/incorrectly lowered #119352

Closed
@bevin-hansson

Description

@bevin-hansson

See the following program: https://godbolt.org/z/YhdKov4x1

There's a number of inconsistencies in how this is emitted.

  • sizeof(_Complex _BitInt(144)) is 48, but the actual size of the declared variable is 64.

  • A struct with two _BitInts has a size of 48, both in sizeof and allocation.

  • The code in the set function is wrong:

    %arrayidx.imagp = getelementptr inbounds i8, ptr %p, i64 32
    store i144 1, ptr %p, align 8
    store i144 1, ptr %arrayidx.imagp, align 8

    If we allocate a memory area of size 48 and then perform these stores, we will write outside of the allocation (32 + 18 = 50).

    Compare this to the set2 function, which designates the imaginary member at offset 24.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions